-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimulated_data.m
112 lines (76 loc) · 3.16 KB
/
simulated_data.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
%% Try routines on simulated data
close all
% clear all
clc
remotepath = mypath();
fdaMPath = [remotepath 'fda'];
addpath(fdaMPath)
%% Generate simulations by hand
% step-like behavior for site = 17 (IGF high-dose)
logyrange = [-.015 .015];
timestamp = linspace(0,1.6981e+03,340);
% step approximately at 127.9 min
step_time = 127.9;
[m step_ind] = min(abs(timestamp - step_time));
tau_step = 8;
mean_amp = range(logyrange);
offset = -.015;
amp_randn = randn(8,1)*ones(1,340);
amp = mean_amp + .15*mean_amp*amp_randn;
off_randn = randn(8,1)*ones(1,340);
offset = offset + .2*offset*off_randn;
%% Plot: Simulation mean
close all
c_signal_mean = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset;
plot(timestamp,c_signal_mean)
%% Plot: Uncorrelated noise - looks not like measured data (mean too well defined)
close all
noise_level = .001;
noise = noise_level*randn(8,340);
c_signal_sim = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset + noise;
plot(timestamp,c_signal_sim)
%% Plot: Correlated noise - looks not like measured data (no oscillations)
close all
noise_level = .0004;
corr_noise = noise_level*randn(8,340);
corr_noise = cumsum(corr_noise,2);
c_signal_corr = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset + corr_noise;
plot(timestamp,c_signal_corr)
%% Plot: Sine modulation - looks not like measured data (oscillations too regular)
close all
sine_freq = .01;
mod_amp = 0.1 * mean_amp;
sine_mod = mod_amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) .* sin(2*pi*sine_freq*repmat(timestamp,8,1));
noise_sine = .001*randn(8,340) + sine_mod;
c_signal_sine = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset + noise_sine;
plot(timestamp,c_signal_sine)
%% Plot: Use cauchy distributed noise - looks not like measured data (extreme jumps)
close all
noise_level = .0001;
noise_cauchy = noise_level .* randn(8,340) ./ randn(8,340);
c_signal_cauchy = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset + noise_cauchy;
plot(timestamp,c_signal_cauchy)
set(gca,'YLim',[-.03 .03])
%% Plot: Additional noise term that is added with certain probability - looks not like measured data (mean too well defined)
close all
noise_level = .0005;
noise_added = noise_level*randn(8,340);
additional_level = noise_level * 10;
additional_prob = 0.2;
additional_noise = additional_level .* randn(8,340) .* (rand(8,340) < additional_prob);
c_signal_added = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset + noise_added + additional_noise;
plot(timestamp,c_signal_added)
%% Plot: Again additional noise, but correlated - looks almost like measured data (but mean hardly visible)
close all
noise_level = .001;
noise_added = noise_level*randn(8,340);
additional_level = noise_level * 3;
additional_prob = 0.1;
additional_noise = additional_level .* randn(8,340) .* (rand(8,340) < additional_prob);
additional_noise_cor = cumsum(additional_noise,2);
c_signal_added_cor = amp./(1+exp(-(repmat(timestamp,8,1)-step_time)/tau_step)) + offset + noise_added + additional_noise_cor;
plot(timestamp,c_signal_added_cor)
return
%% Plot timecourses from measurements to compare with
figure
plot(timestamp,c_signal)