num4anova 0.1.3-java → 0.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/ext/num4anova/Ancova.java +125 -125
- data/lib/num4anova.rb +72 -80
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cee991016acc5e70a9d573a3c854a4c59e0f7d743e68873fe17b0a7e9fd105b3
|
4
|
+
data.tar.gz: f1c465691191a15cc751956129a4bc8470ecec63a14d7cea8bd04faf47df61e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8608fc8d57d8a1da8fa90b54463d0e7a8b8a43cf2f2fe020b7584649a397d952b2d441730af24c9dbcfebae90c73b0953be29934055eca70f408b1e11cec0d0
|
7
|
+
data.tar.gz: d164367e6427c6339b89a6be3ad8e9b43cd7ea6c1a42c8c3c6b3eea0fbe971e723761f7904abe386e9437396a19b3030bcd3d1f60e6abda276ff0e1c8d1e2d88
|
data/CHANGELOG.md
CHANGED
data/ext/num4anova/Ancova.java
CHANGED
@@ -6,38 +6,38 @@ public class Ancova {
|
|
6
6
|
public static Ancova getInstance() {
|
7
7
|
return ancova;
|
8
8
|
}
|
9
|
-
public boolean parallelTest(double[][][] xi, double a) {
|
9
|
+
public boolean parallelTest(double yi[][], double[][] xi, double a) {
|
10
10
|
HypothesisTest hypoth = new Parallettest();
|
11
11
|
|
12
|
-
double statistic = hypoth.calcTestStatistic(xi);
|
12
|
+
double statistic = hypoth.calcTestStatistic(yi, xi);
|
13
13
|
return hypoth.executeTest(statistic, a);
|
14
14
|
}
|
15
|
-
public boolean significanceTest(double[][][] xi, double a) {
|
15
|
+
public boolean significanceTest(double yi[][], double[][] xi, double a) {
|
16
16
|
HypothesisTest hypoth = new SignificanceTest();
|
17
17
|
|
18
|
-
double statistic = hypoth.calcTestStatistic(xi);
|
18
|
+
double statistic = hypoth.calcTestStatistic(yi, xi);
|
19
19
|
return hypoth.executeTest(statistic, a);
|
20
20
|
}
|
21
|
-
public boolean differenceTest(double[][][] xi, double a) {
|
21
|
+
public boolean differenceTest(double yi[][], double[][] xi, double a) {
|
22
22
|
HypothesisTest hypoth = new DifferenceTest();
|
23
23
|
|
24
|
-
double statistic = hypoth.calcTestStatistic(xi);
|
24
|
+
double statistic = hypoth.calcTestStatistic(yi, xi);
|
25
25
|
return hypoth.executeTest(statistic, a);
|
26
26
|
}
|
27
|
-
public Interval[] intervalEstim(double[][][] xi, double a) {
|
27
|
+
public Interval[] intervalEstim(double yi[][], double[][] xi, double a) {
|
28
28
|
Estim estim = new IntervalEstim();
|
29
29
|
|
30
|
-
return estim.calcInterval(xi, a);
|
30
|
+
return estim.calcInterval(yi, xi, a);
|
31
31
|
}
|
32
32
|
/*********************************/
|
33
33
|
/* interface define */
|
34
34
|
/*********************************/
|
35
35
|
private interface HypothesisTest {
|
36
|
-
double calcTestStatistic(double[][][] xi);
|
36
|
+
double calcTestStatistic(double yi[][], double[][] xi);
|
37
37
|
boolean executeTest(double statistic, double a);
|
38
38
|
}
|
39
39
|
private interface Estim {
|
40
|
-
Interval[] calcInterval(double[][][] xi, double a);
|
40
|
+
Interval[] calcInterval(double yi[][], double[][] xi, double a);
|
41
41
|
}
|
42
42
|
/*********************************/
|
43
43
|
/* class define */
|
@@ -53,7 +53,7 @@ public class Ancova {
|
|
53
53
|
public double getMax() { return this.max; }
|
54
54
|
}
|
55
55
|
private class RegressionLine {
|
56
|
-
protected int calcSumn(double[][]
|
56
|
+
protected int calcSumn(double[][] xi) {
|
57
57
|
int sum = 0;
|
58
58
|
|
59
59
|
for(int i = 0; i < xi.length; i++) {
|
@@ -62,69 +62,69 @@ public class Ancova {
|
|
62
62
|
return sum;
|
63
63
|
}
|
64
64
|
// 全変動
|
65
|
-
private double calcSty(double[][]
|
66
|
-
double sumy2 = calcSumy2(
|
67
|
-
double sumy = calcSumy(
|
65
|
+
private double calcSty(double yi[][], int sumn) {
|
66
|
+
double sumy2 = calcSumy2(yi);
|
67
|
+
double sumy = calcSumy(yi);
|
68
68
|
|
69
69
|
return sumy2 - sumy*sumy / sumn;
|
70
70
|
}
|
71
|
-
private double calcStx(double[][]
|
71
|
+
private double calcStx(double[][] xi, int sumn) {
|
72
72
|
double sumx2 = calcSumx2(xi);
|
73
73
|
double sumx = calcSumx(xi);
|
74
74
|
|
75
75
|
return sumx2 - sumx*sumx / sumn;
|
76
76
|
}
|
77
|
-
private double calcStyx(double[][][] xi, int sumn) {
|
77
|
+
private double calcStyx(double yi[][], double[][] xi, int sumn) {
|
78
78
|
double sumx = calcSumx(xi);
|
79
|
-
double sumy = calcSumy(
|
80
|
-
double sumyx = calcSumyx(xi);
|
79
|
+
double sumy = calcSumy(yi);
|
80
|
+
double sumyx = calcSumyx(yi, xi);
|
81
81
|
|
82
82
|
return sumyx - sumy*sumx / sumn;
|
83
83
|
}
|
84
84
|
// 水準間変動
|
85
|
-
private double calcSay(double[][]
|
86
|
-
double sumy = calcSumy(
|
85
|
+
private double calcSay(double yi[][], int sumn) {
|
86
|
+
double sumy = calcSumy(yi);
|
87
87
|
|
88
|
-
return calcSumay(
|
88
|
+
return calcSumay(yi) - sumy*sumy / sumn;
|
89
89
|
}
|
90
|
-
private double calcSax(double[][]
|
90
|
+
private double calcSax(double[][] xi, int sumn) {
|
91
91
|
double sumx = calcSumx(xi);
|
92
92
|
|
93
93
|
return calcSumax(xi) - sumx*sumx / sumn;
|
94
94
|
}
|
95
|
-
private double calcSayx(double[][][] xi, int sumn) {
|
95
|
+
private double calcSayx(double yi[][], double[][] xi, int sumn) {
|
96
96
|
double sumx = calcSumx(xi);
|
97
|
-
double sumy = calcSumy(
|
97
|
+
double sumy = calcSumy(yi);
|
98
98
|
|
99
|
-
return calcSumayx(xi) - sumy*sumx / sumn;
|
99
|
+
return calcSumayx(yi, xi) - sumy*sumx / sumn;
|
100
100
|
}
|
101
101
|
// 水準内変動
|
102
|
-
protected double calcSex(double[][]
|
102
|
+
protected double calcSex(double[][] xi, int sumn) {
|
103
103
|
return calcStx(xi, sumn) - calcSax(xi, sumn);
|
104
104
|
}
|
105
|
-
protected double calcSey(double[][]
|
106
|
-
return calcSty(
|
105
|
+
protected double calcSey(double yi[][], int sumn) {
|
106
|
+
return calcSty(yi, sumn) - calcSay(yi, sumn);
|
107
107
|
}
|
108
|
-
protected double calcSeyx(double[][][] xi, int sumn) {
|
109
|
-
return calcStyx(xi, sumn) - calcSayx(xi, sumn);
|
108
|
+
protected double calcSeyx(double yi[][], double[][] xi, int sumn) {
|
109
|
+
return calcStyx(yi, xi, sumn) - calcSayx(yi, xi, sumn);
|
110
110
|
}
|
111
111
|
|
112
112
|
// 平行性の検定
|
113
|
-
protected double calcbx(double[][][] xi) {
|
113
|
+
protected double calcbx(double yi[][], double[][] xi) {
|
114
114
|
double sum = 0.0;
|
115
115
|
|
116
|
-
for (int i = 0; i <
|
117
|
-
int n =
|
116
|
+
for (int i = 0; i < yi.length; i++) {
|
117
|
+
int n = yi[i].length;
|
118
118
|
double sumx = 0.0;
|
119
119
|
double sumy = 0.0;
|
120
120
|
double sumyx = 0.0;
|
121
121
|
double sumx2 = 0.0;
|
122
122
|
for (int j = 0; j < n; j++) {
|
123
|
-
sumx += xi[i][j]
|
124
|
-
sumy +=
|
125
|
-
sumyx += xi[i][j]
|
123
|
+
sumx += xi[i][j];
|
124
|
+
sumy += yi[i][j];
|
125
|
+
sumyx += xi[i][j] * yi[i][j];
|
126
126
|
|
127
|
-
sumx2 += xi[i][j]
|
127
|
+
sumx2 += xi[i][j] * xi[i][j];
|
128
128
|
|
129
129
|
}
|
130
130
|
double wki = n * sumyx - sumy * sumx;
|
@@ -135,12 +135,12 @@ public class Ancova {
|
|
135
135
|
return sum;
|
136
136
|
}
|
137
137
|
// 差の検定
|
138
|
-
protected double calcSa(double[][][] xi, int sumn) {
|
139
|
-
double sumty = calcSty(
|
140
|
-
double sumtyx = calcStyx(xi, sumn);
|
138
|
+
protected double calcSa(double yi[][], double[][] xi, int sumn) {
|
139
|
+
double sumty = calcSty(yi, sumn);
|
140
|
+
double sumtyx = calcStyx(yi, xi, sumn);
|
141
141
|
double sumtx = calcStx(xi, sumn);
|
142
|
-
double sumey = calcSey(
|
143
|
-
double sumeyx = calcSeyx(xi, sumn);
|
142
|
+
double sumey = calcSey(yi, sumn);
|
143
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
144
144
|
double sumex = calcSex(xi, sumn);
|
145
145
|
|
146
146
|
return (sumty - sumtyx * sumtyx / sumtx)
|
@@ -148,90 +148,90 @@ public class Ancova {
|
|
148
148
|
}
|
149
149
|
|
150
150
|
// ETC
|
151
|
-
private double calcSumay(double[][]
|
151
|
+
private double calcSumay(double yi[][]) {
|
152
152
|
double sum = 0.0;
|
153
153
|
|
154
|
-
for (int i = 0; i <
|
154
|
+
for (int i = 0; i < yi.length; i++) {
|
155
155
|
double sumyi = 0.0;
|
156
|
-
for (int j = 0; j <
|
157
|
-
sumyi +=
|
156
|
+
for (int j = 0; j < yi[i].length; j++) {
|
157
|
+
sumyi += yi[i][j];
|
158
158
|
}
|
159
|
-
sum += sumyi * sumyi /
|
159
|
+
sum += sumyi * sumyi / yi[i].length;
|
160
160
|
}
|
161
161
|
return sum;
|
162
162
|
}
|
163
|
-
private double calcSumy2(double[][]
|
163
|
+
private double calcSumy2(double yi[][]) {
|
164
164
|
double sum = 0.0;
|
165
165
|
|
166
|
-
for (int i = 0; i <
|
167
|
-
for (int j = 0; j <
|
168
|
-
sum +=
|
166
|
+
for (int i = 0; i < yi.length; i++) {
|
167
|
+
for (int j = 0; j < yi[i].length; j++) {
|
168
|
+
sum += yi[i][j] * yi[i][j];
|
169
169
|
}
|
170
170
|
}
|
171
171
|
return sum;
|
172
172
|
}
|
173
|
-
private double calcSumx(double[][]
|
173
|
+
private double calcSumx(double[][] xi) {
|
174
174
|
double sum = 0.0;
|
175
175
|
|
176
176
|
for (int i = 0; i < xi.length; i++) {
|
177
177
|
for (int j = 0; j < xi[i].length; j++) {
|
178
|
-
sum += xi[i][j]
|
178
|
+
sum += xi[i][j];
|
179
179
|
}
|
180
180
|
}
|
181
181
|
return sum;
|
182
182
|
}
|
183
|
-
protected double calcSumx2(double[][]
|
183
|
+
protected double calcSumx2(double[][] xi) {
|
184
184
|
double sum = 0.0;
|
185
185
|
|
186
186
|
for (int i = 0; i < xi.length; i++) {
|
187
187
|
for (int j = 0; j < xi[i].length; j++) {
|
188
|
-
sum += xi[i][j]
|
188
|
+
sum += xi[i][j] * xi[i][j];
|
189
189
|
}
|
190
190
|
}
|
191
191
|
return sum;
|
192
192
|
}
|
193
|
-
protected double calcSumyx(double[][][] xi) {
|
193
|
+
protected double calcSumyx(double yi[][], double[][] xi) {
|
194
194
|
double sum = 0.0;
|
195
195
|
|
196
|
-
for (int i = 0; i <
|
197
|
-
for (int j = 0; j <
|
198
|
-
sum +=
|
196
|
+
for (int i = 0; i < yi.length; i++) {
|
197
|
+
for (int j = 0; j < yi[i].length; j++) {
|
198
|
+
sum += yi[i][j] * xi[i][j];
|
199
199
|
}
|
200
200
|
}
|
201
201
|
return sum;
|
202
202
|
}
|
203
|
-
private double calcSumayx(double[][][] xi) {
|
203
|
+
private double calcSumayx(double yi[][], double[][] xi) {
|
204
204
|
double sum = 0.0;
|
205
205
|
|
206
|
-
for (int i = 0; i <
|
206
|
+
for (int i = 0; i < yi.length; i++) {
|
207
207
|
double sumxi = 0.0;
|
208
208
|
double sumyi = 0.0;
|
209
|
-
for (int j = 0; j <
|
210
|
-
sumxi += xi[i][j]
|
211
|
-
sumyi +=
|
209
|
+
for (int j = 0; j < yi[i].length; j++) {
|
210
|
+
sumxi += xi[i][j];
|
211
|
+
sumyi += yi[i][j];
|
212
212
|
}
|
213
213
|
sum += sumxi * sumyi / xi[i].length;
|
214
214
|
}
|
215
215
|
return sum;
|
216
216
|
}
|
217
|
-
private double calcSumax(double[][]
|
217
|
+
private double calcSumax(double[][] xi) {
|
218
218
|
double sum = 0.0;
|
219
219
|
|
220
220
|
for (int i = 0; i < xi.length; i++) {
|
221
221
|
double sumxi = 0.0;
|
222
222
|
for (int j = 0; j < xi[i].length; j++) {
|
223
|
-
sumxi += xi[i][j]
|
223
|
+
sumxi += xi[i][j];
|
224
224
|
}
|
225
225
|
sum += sumxi * sumxi / xi[i].length;
|
226
226
|
}
|
227
227
|
return sum;
|
228
228
|
}
|
229
|
-
private double calcSumy(double[][]
|
229
|
+
private double calcSumy(double yi[][]) {
|
230
230
|
double sum = 0.0;
|
231
231
|
|
232
|
-
for (int i = 0; i <
|
233
|
-
for (int j = 0; j <
|
234
|
-
sum +=
|
232
|
+
for (int i = 0; i < yi.length; i++) {
|
233
|
+
for (int j = 0; j < yi[i].length; j++) {
|
234
|
+
sum += yi[i][j];
|
235
235
|
}
|
236
236
|
}
|
237
237
|
return sum;
|
@@ -242,32 +242,32 @@ public class Ancova {
|
|
242
242
|
private class Parallettest extends RegressionLine implements HypothesisTest {
|
243
243
|
private int n = 0;
|
244
244
|
private int m = 0;
|
245
|
-
public double calcTestStatistic(double[][][] xi) {
|
245
|
+
public double calcTestStatistic(double yi[][], double[][] xi) {
|
246
246
|
int sumn = calcSumn(xi);
|
247
|
-
n =
|
248
|
-
m = sumn - 2 *
|
247
|
+
n = yi.length - 1;
|
248
|
+
m = sumn - 2 * yi.length;
|
249
249
|
|
250
|
-
double vnp = calcVnp(xi, sumn);
|
251
|
-
double ve2 = calcVe2(xi, sumn);
|
250
|
+
double vnp = calcVnp(yi, xi, sumn);
|
251
|
+
double ve2 = calcVe2(yi, xi, sumn);
|
252
252
|
|
253
253
|
return vnp / ve2;
|
254
254
|
}
|
255
|
-
private double calcVnp(double[][][] xi, int sumn){
|
256
|
-
return calcSnp(xi, sumn) / n;
|
255
|
+
private double calcVnp(double yi[][], double[][] xi, int sumn){
|
256
|
+
return calcSnp(yi, xi, sumn) / n;
|
257
257
|
}
|
258
|
-
private double calcSnp(double[][][] xi, int sumn) {
|
259
|
-
double sumbx = calcbx(xi);
|
260
|
-
double sumeyx = calcSeyx(xi, sumn);
|
258
|
+
private double calcSnp(double yi[][], double[][] xi, int sumn) {
|
259
|
+
double sumbx = calcbx(yi, xi);
|
260
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
261
261
|
double sumex = calcSex(xi, sumn);
|
262
262
|
|
263
263
|
return sumbx - sumeyx * sumeyx / sumex;
|
264
264
|
}
|
265
|
-
private double calcVe2(double[][][] xi, int sumn) {
|
266
|
-
return calcSe2(xi, sumn) / m;
|
265
|
+
private double calcVe2(double yi[][], double[][] xi, int sumn) {
|
266
|
+
return calcSe2(yi, xi, sumn) / m;
|
267
267
|
}
|
268
|
-
private double calcSe2(double[][][] xi, int sumn) {
|
269
|
-
double sumey = calcSey(
|
270
|
-
double sumbx = calcbx(xi);
|
268
|
+
private double calcSe2(double yi[][], double[][] xi, int sumn) {
|
269
|
+
double sumey = calcSey(yi, sumn);
|
270
|
+
double sumbx = calcbx(yi, xi);
|
271
271
|
|
272
272
|
return sumey - sumbx;
|
273
273
|
}
|
@@ -282,13 +282,13 @@ public class Ancova {
|
|
282
282
|
private class SignificanceTest extends RegressionLine implements HypothesisTest {
|
283
283
|
private int n = 0;
|
284
284
|
private int m = 0;
|
285
|
-
public double calcTestStatistic(double[][][] xi) {
|
285
|
+
public double calcTestStatistic(double yi[][], double[][] xi) {
|
286
286
|
int sumn = calcSumn(xi);
|
287
287
|
n = 1;
|
288
288
|
m = sumn - xi.length - 1;
|
289
289
|
|
290
|
-
double vr = calcVr(xi, sumn);
|
291
|
-
double ve = calcVe(xi, sumn);
|
290
|
+
double vr = calcVr(yi, xi, sumn);
|
291
|
+
double ve = calcVe(yi, xi, sumn);
|
292
292
|
|
293
293
|
return vr / ve;
|
294
294
|
}
|
@@ -298,16 +298,16 @@ public class Ancova {
|
|
298
298
|
|
299
299
|
return (statistic >= f) ? true : false;
|
300
300
|
}
|
301
|
-
private double calcVr(double[][][] xi, int sumn) {
|
302
|
-
double sumeyx = calcSeyx(xi, sumn);
|
301
|
+
private double calcVr(double yi[][], double[][] xi, int sumn) {
|
302
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
303
303
|
double sumex = calcSex(xi, sumn);
|
304
304
|
|
305
305
|
return (sumeyx * sumeyx) / sumex;
|
306
306
|
}
|
307
|
-
private double calcVe(double[][][] xi, int sumn) {
|
308
|
-
double sumey = calcSey(
|
307
|
+
private double calcVe(double yi[][], double[][] xi, int sumn) {
|
308
|
+
double sumey = calcSey(yi, sumn);
|
309
309
|
double sumex = calcSex(xi, sumn);
|
310
|
-
double sumeyx = calcSeyx(xi, sumn);
|
310
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
311
311
|
|
312
312
|
return (sumey * sumex - sumeyx * sumeyx) / (m * sumex);
|
313
313
|
}
|
@@ -316,13 +316,13 @@ public class Ancova {
|
|
316
316
|
private class DifferenceTest extends RegressionLine implements HypothesisTest {
|
317
317
|
private int n = 0;
|
318
318
|
private int m = 0;
|
319
|
-
public double calcTestStatistic(double[][][] xi) {
|
319
|
+
public double calcTestStatistic(double yi[][], double[][] xi) {
|
320
320
|
int sumn = calcSumn(xi);
|
321
|
-
n =
|
322
|
-
m = sumn -
|
321
|
+
n = yi.length - 1;
|
322
|
+
m = sumn - yi.length - 1;
|
323
323
|
|
324
|
-
double va = calcSa(xi, sumn) / n;
|
325
|
-
double ve = calcVe(xi, sumn);
|
324
|
+
double va = calcSa(yi, xi, sumn) / n;
|
325
|
+
double ve = calcVe(yi, xi, sumn);
|
326
326
|
|
327
327
|
return va / ve;
|
328
328
|
}
|
@@ -332,10 +332,10 @@ public class Ancova {
|
|
332
332
|
|
333
333
|
return (statistic >= f) ? true : false;
|
334
334
|
}
|
335
|
-
private double calcVe(double[][][] xi, int sumn) {
|
336
|
-
double sumey = calcSey(
|
335
|
+
private double calcVe(double yi[][], double[][] xi, int sumn) {
|
336
|
+
double sumey = calcSey(yi, sumn);
|
337
337
|
double sumex = calcSex(xi, sumn);
|
338
|
-
double sumeyx = calcSeyx(xi, sumn);
|
338
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
339
339
|
|
340
340
|
return (sumey * sumex - sumeyx * sumeyx) / (m * sumex);
|
341
341
|
}
|
@@ -346,16 +346,16 @@ public class Ancova {
|
|
346
346
|
private int n = 0;
|
347
347
|
private int[] ni = null;
|
348
348
|
private double sumex = 0.0;
|
349
|
-
public Interval[] calcInterval(double[][][] xi, double a) {
|
349
|
+
public Interval[] calcInterval(double yi[][], double[][] xi, double a) {
|
350
350
|
Interval[] ret = new Interval[xi.length];
|
351
|
-
ni = calcNi(
|
351
|
+
ni = calcNi(yi);
|
352
352
|
int sumn = calcSumn(xi);
|
353
353
|
n = sumn - xi.length - 1;
|
354
354
|
sumex = calcSex(xi, sumn);
|
355
|
-
double ve = calcVe(xi, sumn);
|
356
|
-
double b = calcB(xi, sumn);
|
355
|
+
double ve = calcVe(yi, xi, sumn);
|
356
|
+
double b = calcB(yi, xi, sumn);
|
357
357
|
|
358
|
-
double[] meanyi = calcMeanyi(
|
358
|
+
double[] meanyi = calcMeanyi(yi);
|
359
359
|
double[] meanxi = calcMeanxi(xi);
|
360
360
|
double meanx = calcMeanx(xi);
|
361
361
|
|
@@ -372,56 +372,56 @@ public class Ancova {
|
|
372
372
|
|
373
373
|
return ret;
|
374
374
|
}
|
375
|
-
private int[] calcNi(double[][]
|
376
|
-
int[] ni = new int[
|
375
|
+
private int[] calcNi(double[][] yi) {
|
376
|
+
int[] ni = new int[yi.length];
|
377
377
|
|
378
|
-
for(int i = 0; i <
|
379
|
-
ni[i] =
|
378
|
+
for(int i = 0; i < yi.length; i++) {
|
379
|
+
ni[i] = yi[i].length;
|
380
380
|
}
|
381
381
|
return ni;
|
382
382
|
}
|
383
|
-
private double calcVe(double[][][] xi, int sumn) {
|
384
|
-
double sumey = calcSey(
|
385
|
-
double sumeyx = calcSeyx(xi, sumn);
|
383
|
+
private double calcVe(double[][] yi, double[][] xi, int sumn) {
|
384
|
+
double sumey = calcSey(yi, sumn);
|
385
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
386
386
|
|
387
387
|
return (sumey * sumex - sumeyx * sumeyx) / (n * sumex);
|
388
388
|
}
|
389
|
-
private double calcB(double[][][] xi, int sumn) {
|
390
|
-
double sumeyx = calcSeyx(xi, sumn);
|
389
|
+
private double calcB(double[][] yi, double[][] xi, int sumn) {
|
390
|
+
double sumeyx = calcSeyx(yi, xi, sumn);
|
391
391
|
double sex = calcSex(xi, sumn);
|
392
392
|
|
393
393
|
return sumeyx / sex;
|
394
394
|
}
|
395
|
-
private double[] calcMeanyi(double[][]
|
396
|
-
double[] meanyi = new double[
|
395
|
+
private double[] calcMeanyi(double[][] yi) {
|
396
|
+
double[] meanyi = new double[yi.length];
|
397
397
|
|
398
|
-
for(int i = 0; i <
|
398
|
+
for(int i = 0; i < yi.length; i++) {
|
399
399
|
double sum = 0.0;
|
400
|
-
for(int j = 0; j <
|
401
|
-
sum +=
|
400
|
+
for(int j = 0; j < yi[i].length; j++) {
|
401
|
+
sum += yi[i][j];
|
402
402
|
}
|
403
|
-
meanyi[i] = sum /
|
403
|
+
meanyi[i] = sum / yi[i].length;
|
404
404
|
}
|
405
405
|
return meanyi;
|
406
406
|
}
|
407
|
-
private double[] calcMeanxi(double[][]
|
407
|
+
private double[] calcMeanxi(double[][] xi) {
|
408
408
|
double[] meanxi = new double[xi.length];
|
409
409
|
|
410
410
|
for(int i = 0; i < xi.length; i++) {
|
411
411
|
double sum = 0.0;
|
412
412
|
for(int j = 0; j < xi[i].length; j++) {
|
413
|
-
sum += xi[i][j]
|
413
|
+
sum += xi[i][j];
|
414
414
|
}
|
415
415
|
meanxi[i] = sum / xi[i].length;
|
416
416
|
}
|
417
417
|
return meanxi;
|
418
418
|
}
|
419
|
-
private double calcMeanx(double[][]
|
419
|
+
private double calcMeanx(double[][] xi) {
|
420
420
|
double sum = 0.0;
|
421
421
|
double n = 0;
|
422
422
|
for(int i = 0; i < xi.length; i++) {
|
423
423
|
for(int j = 0; j < xi[i].length; j++) {
|
424
|
-
sum += xi[i][j]
|
424
|
+
sum += xi[i][j];
|
425
425
|
n++;
|
426
426
|
}
|
427
427
|
}
|
data/lib/num4anova.rb
CHANGED
@@ -306,129 +306,121 @@ module Num4AnovaLib
|
|
306
306
|
end
|
307
307
|
# 回帰直線の平行性検定
|
308
308
|
#
|
309
|
-
# @overload parallel_test(xi, a)
|
310
|
-
# @param [array]
|
309
|
+
# @overload parallel_test(yi, xi, a)
|
310
|
+
# @param [array] yi データ(double[][])
|
311
|
+
# @param [array] xi データ(double[][])
|
311
312
|
# @param [double] a 有意水準
|
312
313
|
# @return [boolean] 検定結果(boolean true:棄却域内 false:棄却域外)
|
313
314
|
# @example
|
315
|
+
# yi = [
|
316
|
+
# [3, 5, 3],
|
317
|
+
# [3, 3, 8],
|
318
|
+
# [2, 2, 2],
|
319
|
+
# [3, 4, 2],
|
320
|
+
# [1, 2, 0],
|
321
|
+
# ]
|
314
322
|
# xi = [
|
315
|
-
# [
|
316
|
-
#
|
317
|
-
# ],
|
318
|
-
# [
|
319
|
-
#
|
320
|
-
# ],
|
321
|
-
# [
|
322
|
-
# [2,40], [2,45], [2,39],
|
323
|
-
# ],
|
324
|
-
# [
|
325
|
-
# [3,47], [4,52], [2,48],
|
326
|
-
# ],
|
327
|
-
# [
|
328
|
-
# [1,64], [2,80], [0,70],
|
329
|
-
# ],
|
323
|
+
# [35, 38, 39],
|
324
|
+
# [36, 39, 54],
|
325
|
+
# [40, 45, 39],
|
326
|
+
# [47, 52, 48],
|
327
|
+
# [64, 80, 70],
|
330
328
|
# ]
|
331
329
|
# ancova = Num4AnovaLib::Num4AncovaLib.new
|
332
|
-
# ancova.parallel_test(xi, 0.05)
|
330
|
+
# ancova.parallel_test(yi, xi, 0.05)
|
333
331
|
# => false
|
334
|
-
def parallel_test(xi, a)
|
335
|
-
@ancova.parallelTest(
|
332
|
+
def parallel_test(yi, xi, a)
|
333
|
+
@ancova.parallelTest(yi.to_java(Java::double[]), xi.to_java(Java::double[]), a)
|
336
334
|
end
|
337
335
|
# 回帰直線の有意性検定
|
338
336
|
#
|
339
|
-
# @overload significance_test(xi, a)
|
340
|
-
# @param [array]
|
337
|
+
# @overload significance_test(yi, xi, a)
|
338
|
+
# @param [array] yi データ(double[][])
|
339
|
+
# @param [array] xi データ(double[][])
|
341
340
|
# @param [double] a 有意水準
|
342
341
|
# @return [boolean] 検定結果(boolean true:棄却域内 false:棄却域外)
|
343
342
|
# @example
|
343
|
+
# yi = [
|
344
|
+
# [3, 5, 3],
|
345
|
+
# [3, 3, 8],
|
346
|
+
# [2, 2, 2],
|
347
|
+
# [3, 4, 2],
|
348
|
+
# [1, 2, 0],
|
349
|
+
# ]
|
344
350
|
# xi = [
|
345
|
-
# [
|
346
|
-
#
|
347
|
-
# ],
|
348
|
-
# [
|
349
|
-
#
|
350
|
-
# ],
|
351
|
-
# [
|
352
|
-
# [2,40], [2,45], [2,39],
|
353
|
-
# ],
|
354
|
-
# [
|
355
|
-
# [3,47], [4,52], [2,48],
|
356
|
-
# ],
|
357
|
-
# [
|
358
|
-
# [1,64], [2,80], [0,70],
|
359
|
-
# ],
|
351
|
+
# [35, 38, 39],
|
352
|
+
# [36, 39, 54],
|
353
|
+
# [40, 45, 39],
|
354
|
+
# [47, 52, 48],
|
355
|
+
# [64, 80, 70],
|
360
356
|
# ]
|
361
357
|
# ancova = Num4AnovaLib::Num4AncovaLib.new
|
362
|
-
# ancova.significance_test(xi, 0.05)
|
358
|
+
# ancova.significance_test(yi, xi, 0.05)
|
363
359
|
# => true
|
364
|
-
def significance_test(xi, a)
|
365
|
-
@ancova.significanceTest(
|
360
|
+
def significance_test(yi, xi, a)
|
361
|
+
@ancova.significanceTest(yi.to_java(Java::double[]), xi.to_java(Java::double[]), a)
|
366
362
|
end
|
367
363
|
# 水準間の差の検定
|
368
364
|
#
|
369
|
-
# @overload difference_test(xi, a)
|
370
|
-
# @param [array]
|
365
|
+
# @overload difference_test(yi, xi, a)
|
366
|
+
# @param [array] yi データ(double[][])
|
367
|
+
# @param [array] xi データ(double[][])
|
371
368
|
# @param [double] a 有意水準
|
372
369
|
# @return [boolean] 検定結果(boolean true:棄却域内 false:棄却域外)
|
373
370
|
# @example
|
371
|
+
# yi = [
|
372
|
+
# [3, 5, 3],
|
373
|
+
# [3, 3, 8],
|
374
|
+
# [2, 2, 2],
|
375
|
+
# [3, 4, 2],
|
376
|
+
# [1, 2, 0],
|
377
|
+
# ]
|
374
378
|
# xi = [
|
375
|
-
# [
|
376
|
-
#
|
377
|
-
# ],
|
378
|
-
# [
|
379
|
-
#
|
380
|
-
# ],
|
381
|
-
# [
|
382
|
-
# [2,40], [2,45], [2,39],
|
383
|
-
# ],
|
384
|
-
# [
|
385
|
-
# [3,47], [4,52], [2,48],
|
386
|
-
# ],
|
387
|
-
# [
|
388
|
-
# [1,64], [2,80], [0,70],
|
389
|
-
# ],
|
379
|
+
# [35, 38, 39],
|
380
|
+
# [36, 39, 54],
|
381
|
+
# [40, 45, 39],
|
382
|
+
# [47, 52, 48],
|
383
|
+
# [64, 80, 70],
|
390
384
|
# ]
|
391
385
|
# ancova = Num4AnovaLib::Num4AncovaLib.new
|
392
|
-
# ancova.difference_test(xi, 0.05)
|
386
|
+
# ancova.difference_test(yi, xi, 0.05)
|
393
387
|
# => true
|
394
|
-
def difference_test(xi, a)
|
395
|
-
@ancova.differenceTest(
|
388
|
+
def difference_test(yi, xi, a)
|
389
|
+
@ancova.differenceTest(yi.to_java(Java::double[]), xi.to_java(Java::double[]), a)
|
396
390
|
end
|
397
391
|
# 区間推定
|
398
392
|
#
|
399
|
-
# @overload interval_estim(xi, a)
|
400
|
-
# @param [array]
|
393
|
+
# @overload interval_estim(yi, xi, a)
|
394
|
+
# @param [array] yi データ(double[][])
|
395
|
+
# @param [array] xi データ(double[][])
|
401
396
|
# @param [double] a 有意水準
|
402
397
|
# @return [Hash] (min:下限信頼区間 max:上限信頼区間)
|
403
398
|
# @example
|
399
|
+
# yi = [
|
400
|
+
# [3, 5, 3],
|
401
|
+
# [3, 3, 8],
|
402
|
+
# [2, 2, 2],
|
403
|
+
# [3, 4, 2],
|
404
|
+
# [1, 2, 0],
|
405
|
+
# ]
|
404
406
|
# xi = [
|
405
|
-
# [
|
406
|
-
#
|
407
|
-
# ],
|
408
|
-
# [
|
409
|
-
#
|
410
|
-
# ],
|
411
|
-
# [
|
412
|
-
# [2,40], [2,45], [2,39],
|
413
|
-
# ],
|
414
|
-
# [
|
415
|
-
# [3,47], [4,52], [2,48],
|
416
|
-
# ],
|
417
|
-
# [
|
418
|
-
# [1,64], [2,80], [0,70],
|
419
|
-
# ],
|
407
|
+
# [35, 38, 39],
|
408
|
+
# [36, 39, 54],
|
409
|
+
# [40, 45, 39],
|
410
|
+
# [47, 52, 48],
|
411
|
+
# [64, 80, 70],
|
420
412
|
# ]
|
421
413
|
# ancova = Num4AnovaLib::Num4AncovaLib.new
|
422
|
-
# ancova.interval_estim(xi, 0.05)
|
414
|
+
# ancova.interval_estim(yi, xi, 0.05)
|
423
415
|
# =>
|
424
416
|
# {:min=>4.466605469341916, :max=>7.1909253948556096}
|
425
417
|
# {:min=>5.05699825110459, :max=>6.386335082228742}
|
426
418
|
# {:min=>2.510804295684195, :max=>4.250430272217034}
|
427
419
|
# {:min=>2.8089257316042135, :max=>2.9566298239513418}
|
428
420
|
# {:min=>-6.303283147572267, :max=>-0.6577045067487104}
|
429
|
-
def interval_estim(xi, a)
|
421
|
+
def interval_estim(yi, xi, a)
|
430
422
|
retRb = []
|
431
|
-
retJava = @ancova.intervalEstim(
|
423
|
+
retJava = @ancova.intervalEstim(yi.to_java(Java::double[]), xi.to_java(Java::double[]), a)
|
432
424
|
sz = retJava.size
|
433
425
|
sz.times do |i|
|
434
426
|
retRb.push(
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: num4anova
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1
|
4
|
+
version: 0.2.1
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|