num4anova 0.0.10-java → 0.0.11-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 +5 -0
- data/ext/num4anova/Ancova.java +83 -16
- data/lib/num4anova.rb +31 -1
- 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: 2a278a4c32d7e1ef21ccbb1200573d5c1b4e326c59602327f9968afb29f134b6
|
4
|
+
data.tar.gz: e8520453d70e0276e6bb0587aefcd31b90b84d703cf670ae25297af73172bcdd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42836d15f6460c2650a7c6cb17c15de206bbabb52c40d988714fe26564d019974a416db4c22f67ed0c535694022575d380603da7c029f0b04476d4994ffca7a5
|
7
|
+
data.tar.gz: ed1698ed0b05da8d2f0d7417fd1271bcb41754d76fa68b19fb300245449a634c830636ea790a49b89d87066c320c55e2260464bb791ba795f8193664a0babb28
|
data/CHANGELOG.md
CHANGED
data/ext/num4anova/Ancova.java
CHANGED
@@ -17,6 +17,12 @@ public class Ancova {
|
|
17
17
|
double statistic = hypoth.calcTestStatistic(xi);
|
18
18
|
return hypoth.executeTest(statistic, a);
|
19
19
|
}
|
20
|
+
public boolean differenceTest(double[][][] xi, double a) {
|
21
|
+
HypothesisTest hypoth = new DifferenceTest();
|
22
|
+
|
23
|
+
double statistic = hypoth.calcTestStatistic(xi);
|
24
|
+
return hypoth.executeTest(statistic, a);
|
25
|
+
}
|
20
26
|
/*********************************/
|
21
27
|
/* interface define */
|
22
28
|
/*********************************/
|
@@ -36,34 +42,54 @@ public class Ancova {
|
|
36
42
|
}
|
37
43
|
return sum;
|
38
44
|
}
|
39
|
-
|
45
|
+
// 全変動
|
46
|
+
private double calcSty(double[][][] xi, int sumn) {
|
47
|
+
double sumy2 = calcSumy2(xi);
|
48
|
+
double sumy = calcSumy(xi);
|
49
|
+
|
50
|
+
return sumy2 - sumy*sumy / sumn;
|
51
|
+
}
|
52
|
+
private double calcStx(double[][][] xi, int sumn) {
|
40
53
|
double sumx2 = calcSumx2(xi);
|
41
54
|
double sumx = calcSumx(xi);
|
42
55
|
|
43
|
-
|
44
|
-
|
56
|
+
return sumx2 - sumx*sumx / sumn;
|
57
|
+
}
|
58
|
+
private double calcStyx(double[][][] xi, int sumn) {
|
59
|
+
double sumx = calcSumx(xi);
|
60
|
+
double sumy = calcSumy(xi);
|
61
|
+
double sumyx = calcSumyx(xi);
|
45
62
|
|
46
|
-
return
|
63
|
+
return sumyx - sumy*sumx / sumn;
|
47
64
|
}
|
48
|
-
|
49
|
-
|
65
|
+
// 水準間変動
|
66
|
+
private double calcSay(double[][][] xi, int sumn) {
|
50
67
|
double sumy = calcSumy(xi);
|
51
68
|
|
52
|
-
|
53
|
-
|
69
|
+
return calcSumay(xi) - sumy*sumy / sumn;
|
70
|
+
}
|
71
|
+
private double calcSax(double[][][] xi, int sumn) {
|
72
|
+
double sumx = calcSumx(xi);
|
54
73
|
|
55
|
-
return
|
74
|
+
return calcSumax(xi) - sumx*sumx / sumn;
|
56
75
|
}
|
57
|
-
|
76
|
+
private double calcSayx(double[][][] xi, int sumn) {
|
58
77
|
double sumx = calcSumx(xi);
|
59
78
|
double sumy = calcSumy(xi);
|
60
|
-
double sumyx = calcSumyx(xi);
|
61
|
-
|
62
|
-
double sumayx = calcSumayx(xi) - sumy*sumx / sumn;
|
63
|
-
double sumtyx = sumyx - sumy*sumx / sumn;
|
64
79
|
|
65
|
-
return
|
80
|
+
return calcSumayx(xi) - sumy*sumx / sumn;
|
81
|
+
}
|
82
|
+
// 水準内変動
|
83
|
+
protected double calcSex(double[][][] xi, int sumn) {
|
84
|
+
return calcStx(xi, sumn) - calcSax(xi, sumn);
|
85
|
+
}
|
86
|
+
protected double calcSey(double[][][] xi, int sumn) {
|
87
|
+
return calcSty(xi, sumn) - calcSay(xi, sumn);
|
66
88
|
}
|
89
|
+
protected double calcSeyx(double[][][] xi, int sumn) {
|
90
|
+
return calcStyx(xi, sumn) - calcSayx(xi, sumn);
|
91
|
+
}
|
92
|
+
|
67
93
|
// 平行性の検定
|
68
94
|
protected double calcbx(double[][][] xi) {
|
69
95
|
double sum = 0.0;
|
@@ -89,8 +115,20 @@ public class Ancova {
|
|
89
115
|
}
|
90
116
|
return sum;
|
91
117
|
}
|
118
|
+
// 差の検定
|
119
|
+
protected double calcSa(double[][][] xi, int sumn) {
|
120
|
+
double sumty = calcSty(xi, sumn);
|
121
|
+
double sumtyx = calcStyx(xi, sumn);
|
122
|
+
double sumtx = calcStx(xi, sumn);
|
123
|
+
double sumey = calcSey(xi, sumn);
|
124
|
+
double sumeyx = calcSeyx(xi, sumn);
|
125
|
+
double sumex = calcSex(xi, sumn);
|
92
126
|
|
127
|
+
return (sumty - sumtyx * sumtyx / sumtx)
|
128
|
+
- (sumey - sumeyx * sumeyx / sumex);
|
129
|
+
}
|
93
130
|
|
131
|
+
// ETC
|
94
132
|
private double calcSumay(double[][][] xi) {
|
95
133
|
double sum = 0.0;
|
96
134
|
|
@@ -157,7 +195,6 @@ public class Ancova {
|
|
157
195
|
}
|
158
196
|
return sum;
|
159
197
|
}
|
160
|
-
// 水準間変動
|
161
198
|
private double calcSumax(double[][][] xi) {
|
162
199
|
double sum = 0.0;
|
163
200
|
|
@@ -180,6 +217,7 @@ public class Ancova {
|
|
180
217
|
}
|
181
218
|
return sum;
|
182
219
|
}
|
220
|
+
|
183
221
|
}
|
184
222
|
// 回帰直線モデルの平行性の検定
|
185
223
|
private class Parallettest extends RegressionLine implements HypothesisTest {
|
@@ -232,6 +270,7 @@ public class Ancova {
|
|
232
270
|
|
233
271
|
double vr = calcVr(xi, sumn);
|
234
272
|
double ve = calcVe(xi, sumn);
|
273
|
+
|
235
274
|
return vr / ve;
|
236
275
|
}
|
237
276
|
public boolean executeTest(double statistic, double a) {
|
@@ -251,6 +290,34 @@ public class Ancova {
|
|
251
290
|
double sumex = calcSex(xi, sumn);
|
252
291
|
double sumeyx = calcSeyx(xi, sumn);
|
253
292
|
|
293
|
+
return (sumey * sumex - sumeyx * sumeyx) / (m * sumex);
|
294
|
+
}
|
295
|
+
}
|
296
|
+
// 水準間の差の検定
|
297
|
+
private class DifferenceTest extends RegressionLine implements HypothesisTest {
|
298
|
+
private int n = 0;
|
299
|
+
private int m = 0;
|
300
|
+
public double calcTestStatistic(double[][][] xi) {
|
301
|
+
int sumn = calcSumn(xi);
|
302
|
+
n = xi.length - 1;
|
303
|
+
m = sumn - xi.length - 1;
|
304
|
+
|
305
|
+
double va = calcSa(xi, sumn) / n;
|
306
|
+
double ve = calcVe(xi, sumn);
|
307
|
+
|
308
|
+
return va / ve;
|
309
|
+
}
|
310
|
+
public boolean executeTest(double statistic, double a) {
|
311
|
+
FDistribution fDist = new FDistribution(n, m);
|
312
|
+
double f = fDist.inverseCumulativeProbability(1.0 - a);
|
313
|
+
|
314
|
+
return (statistic >= f) ? true : false;
|
315
|
+
}
|
316
|
+
private double calcVe(double[][][] xi, int sumn) {
|
317
|
+
double sumey = calcSey(xi, sumn);
|
318
|
+
double sumex = calcSex(xi, sumn);
|
319
|
+
double sumeyx = calcSeyx(xi, sumn);
|
320
|
+
|
254
321
|
return (sumey * sumex - sumeyx * sumeyx) / (m * sumex);
|
255
322
|
}
|
256
323
|
}
|
data/lib/num4anova.rb
CHANGED
@@ -256,7 +256,7 @@ module Num4AnovaLib
|
|
256
256
|
end
|
257
257
|
# 回帰直線の有意性検定
|
258
258
|
#
|
259
|
-
# @overload
|
259
|
+
# @overload significance_test(xi, a)
|
260
260
|
# @param [array] xi データ(double[][][])
|
261
261
|
# @param [double] a 有意水準
|
262
262
|
# @return [boolean] 検定結果(boolean true:棄却域内 false:棄却域外)
|
@@ -284,6 +284,36 @@ module Num4AnovaLib
|
|
284
284
|
def significance_test(xi, a)
|
285
285
|
@ancova.significanceTest(xi.to_java(Java::double[][]), a)
|
286
286
|
end
|
287
|
+
# 水準間の差の検定
|
288
|
+
#
|
289
|
+
# @overload difference_test(xi, a)
|
290
|
+
# @param [array] xi データ(double[][][])
|
291
|
+
# @param [double] a 有意水準
|
292
|
+
# @return [boolean] 検定結果(boolean true:棄却域内 false:棄却域外)
|
293
|
+
# @example
|
294
|
+
# xi = [
|
295
|
+
# [
|
296
|
+
# [3,35], [5,38], [3,39],
|
297
|
+
# ],
|
298
|
+
# [
|
299
|
+
# [3,36], [3,39], [8,54],
|
300
|
+
# ],
|
301
|
+
# [
|
302
|
+
# [2,40], [2,45], [2,39],
|
303
|
+
# ],
|
304
|
+
# [
|
305
|
+
# [3,47], [4,52], [2,48],
|
306
|
+
# ],
|
307
|
+
# [
|
308
|
+
# [1,64], [2,80], [0,70],
|
309
|
+
# ],
|
310
|
+
# ]
|
311
|
+
# ancova = Num4AnovaLib::Num4AncovaLib.new
|
312
|
+
# ancova.difference_test(xi, 0.05)
|
313
|
+
# => true
|
314
|
+
def difference_test(xi, a)
|
315
|
+
@ancova.differenceTest(xi.to_java(Java::double[][]), a)
|
316
|
+
end
|
287
317
|
end
|
288
318
|
end
|
289
319
|
|
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.0.
|
4
|
+
version: 0.0.11
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|