-
Notifications
You must be signed in to change notification settings - Fork 1
/
RunSimulationIID.m
148 lines (143 loc) · 3.6 KB
/
RunSimulationIID.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
%% OBS: It took more than a month to run the script on a regular PC.
addpath('..');
%% One-sample t-test
test='OST';
for n=[2 3 5]
for dist=[0 2 3]
if dist==0
h=@(x) pdf('Uniform',x,-1,1);
Kg=OSTComputeKgIID(n,h,1e-6,@quad);
elseif dist==2
h=@(x) pdf('Exponential',x+1,1);
Kg=OSTComputeKgIID(n,h,1e-6,@quadl);
elseif dist==3
h=@(x) pdf('t',x,dist-2);
Kg=OSTComputeKgIID(n,h,1e-6,@quadl);
else
return;
end
for r=[1 20 100 1000 10000 100000 1000000]
display(['test=' test...
' n=' num2str(n)...
' dist=' num2str(dist)...
' r=' num2str(r)]);
tic;
OSTSimulatePValues(dist,n,r,Kg);
toc
end
end
end
%% Two-sample t-test
test='TST';
for n2=[2 3 5]
if (n2==2)
n1=2;
elseif (n2==3)
n1=2;
elseif (n2==5)
n1=3;
else
return;
end
for dist=[0 2 4]
if dist==0
h=@(x) pdf('Uniform',x,-1,1);
Kg=TSTComputeKgIID(n1,n2,h,1e-6,@quad);
elseif dist==2
h=@(x) pdf('Exponential',x+1,1);
Kg=TSTComputeKgIID(n1,n2,h,1e-6,@quadl);
elseif dist==4
h=@(x) pdf('t',x,dist-2);
Kg=TSTComputeKgIID(n1,n2,h,1e-6,@quadl);
else
return;
end
for r=[1 20 100 1000 10000 100000 1000000]
display(['test=' test...
' n1=' num2str(n1)...
' n2=' num2str(n2)...
' dist=' num2str(dist)...
' r=' num2str(r)]);
tic;
TSTSimulatePValues(dist,n1,n2,r,Kg);
toc
end
end
end
%% Welch t-test
test='WELCH';
for n2=[2 3 5]
if (n2==2)
n1=2;
elseif (n2==3)
n1=2;
elseif (n2==5)
n1=3;
else
return;
end
for dist=1
if dist==0
h=@(x) pdf('Uniform',x,-1,1);
Kg=WELCHComputeKgIID(n1,n2,h,1e-6,@quad);
elseif dist==1
h=@(x) pdf('Normal',x,0,1);
Kg=WELCHComputeKgIID(n1,n2,h,1e-6,@quadl);
elseif dist==2
h=@(x) pdf('Exponential',x+1,1);
Kg=WELCHComputeKgIID(n1,n2,h,1e-6,@quadl);
elseif dist==4
h=@(x) pdf('t',x,dist-2);
Kg=WELCHComputeKgIID(n1,n2,h,1e-6,@quadl);
else
return;
end
for r=[1 20 100 1000 10000 100000 1000000]
display(['test=' test...
' n1=' num2str(n1)...
' n2=' num2str(n2)...
' dist=' num2str(dist)...
' r=' num2str(r)]);
tic;
WELCHSimulatePValues(dist,n1,n2,r,Kg);
toc
end
end
end
%% F-test
test='F';
for n2=[5 3 2 ]
if (n2==2)
n1=2;
elseif (n2==3)
n1=2;
elseif (n2==5)
n1=3;
else
return;
end
for dist=[0 2 7]
if dist==0
h=@(x) pdf('Uniform',x,-1,1);
Kg=FComputeKgIID(n1,n2,h,1e-6,@quad);
elseif dist==2
h=@(x) pdf('Exponential',x,1);
Kg=FComputeKgIID(n1,n2,h,1e-6,@quadl);
elseif dist==7
h=@(x) pdf('t',x,dist-2);
Kg=FComputeKgIID(n1,n2,h,1e-6,@quadl);
else
return;
end
for r=[1 20 100 1000 10000 100000 1000000]
display(['test=' test...
' n1=' num2str(n1)...
' n2=' num2str(n2)...
' dist=' num2str(dist)...
' r=' num2str(r)]);
tic;
FSimulatePValues(dist,n1,n2,r,Kg);
toc
end
end
end