num4hypothtst 0.0.2-java → 0.0.4-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 +18 -0
- data/ext/num4hypothtst/hypothtst/GrubbsTest.java +34 -0
- data/ext/num4hypothtst/{HypothTest.java → hypothtst/HypothTest.java} +3 -1
- data/ext/num4hypothtst/{LeftSideTest.java → hypothtst/LeftSideTest.java} +5 -2
- data/ext/num4hypothtst/{RightSideTest.java → hypothtst/RightSideTest.java} +4 -2
- data/ext/num4hypothtst/{TwoSideTest.java → hypothtst/TwoSideTest.java} +4 -2
- data/lib/num4hypothtst.rb +63 -36
- metadata +15 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 036effc8d6ceec1112745a846f5ea5a0c64b0ddbf5dedc1b539686a0549e4128
|
4
|
+
data.tar.gz: 8f77c2093ac590b8afa5a2cfbfa2766e6e115a0d5838bee9ae4258d90b6264fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a49287883d7fe6a45a96e51e7e5028870c3e8ee3940ad85eb8ca786b96ef5e0326c48278a42ea680d2a80db7014cda5ab4ffb7b2bce717b3fd62b4135aaeb27
|
7
|
+
data.tar.gz: ae6a3bbb3c09af2ac945f79554c5e5127c8abe92456bae57fd9485ccd6560b24c53397610be34632fe12547b1c73cbc67eab35e708e9ffe9f15bd7e16c13f849
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## [0.0.4] - 2023-10-13
|
6
|
+
|
7
|
+
### change
|
8
|
+
- chg gnTest
|
9
|
+
|
10
|
+
## [0.0.3] - 2023-10-05
|
11
|
+
|
12
|
+
### change
|
13
|
+
- chg name of function to normDistTest from normDistest.
|
14
|
+
|
15
|
+
### add
|
16
|
+
- add function of gnTest.
|
17
|
+
|
18
|
+
## [0.0.2] - 2023-10-02
|
19
|
+
|
20
|
+
### change
|
21
|
+
- chg url of homepage
|
22
|
+
|
5
23
|
## [0.0.1] - 2023-10-02
|
6
24
|
|
7
25
|
### Fixed
|
@@ -0,0 +1,34 @@
|
|
1
|
+
package hypothtst;
|
2
|
+
|
3
|
+
import org.apache.commons.math3.distribution.TDistribution;
|
4
|
+
// グラブス・スミルノフの外れ値の検定
|
5
|
+
public class GrubbsTest {
|
6
|
+
private static GrubbsTest grubbs = new GrubbsTest();
|
7
|
+
public static GrubbsTest getInstance() {
|
8
|
+
return grubbs;
|
9
|
+
}
|
10
|
+
public boolean twoSideTest(double statistic, int n, double a) {
|
11
|
+
double r_val = calcGnValue(n, a / 2.0);
|
12
|
+
return evaluation(statistic, r_val);
|
13
|
+
}
|
14
|
+
public boolean oneSideTest(double statistic, int n, double a) {
|
15
|
+
double r_val = calcGnValue(n, a);
|
16
|
+
return evaluation(statistic, r_val);
|
17
|
+
}
|
18
|
+
private double calcGnValue(int n, double a) {
|
19
|
+
TDistribution tDist = new TDistribution(n);
|
20
|
+
double t = tDist.inverseCumulativeProbability(a / n);
|
21
|
+
double gn = (n - 1) * t / Math.sqrt(n * (n - 2 + t * t));
|
22
|
+
|
23
|
+
return Math.abs(gn);
|
24
|
+
}
|
25
|
+
private boolean evaluation(double statistic, double r_val) {
|
26
|
+
boolean ret = true;
|
27
|
+
|
28
|
+
if (Math.abs(statistic) < r_val) {
|
29
|
+
ret = false;
|
30
|
+
}
|
31
|
+
return ret;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
@@ -1,8 +1,10 @@
|
|
1
|
+
package hypothtst;
|
2
|
+
|
1
3
|
// 仮設検定
|
2
4
|
interface HypothTest {
|
3
5
|
boolean tDistTest(double statistic, double df, double a);
|
4
6
|
boolean chi2DistTest(double statistic, double df, double a);
|
5
|
-
boolean
|
7
|
+
boolean normDistTest(double statistic, double a);
|
6
8
|
boolean fDistTest(double statistic, double nf, double df, double a);
|
7
9
|
}
|
8
10
|
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
package hypothtst;
|
2
|
+
|
2
3
|
import org.apache.commons.math3.distribution.TDistribution;
|
3
4
|
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
4
5
|
import org.apache.commons.math3.distribution.NormalDistribution;
|
5
6
|
import org.apache.commons.math3.distribution.FDistribution;
|
6
7
|
|
8
|
+
// 片側検定(左側)
|
7
9
|
public class LeftSideTest implements HypothTest {
|
8
10
|
private static HypothTest hupothTest = new LeftSideTest();
|
9
11
|
public static HypothTest getInstance() {
|
@@ -21,7 +23,7 @@ public class LeftSideTest implements HypothTest {
|
|
21
23
|
|
22
24
|
return evaluation(statistic, l_val);
|
23
25
|
}
|
24
|
-
public boolean
|
26
|
+
public boolean normDistTest(double statistic, double a) {
|
25
27
|
NormalDistribution norDist = new NormalDistribution(0, 1);
|
26
28
|
double l_val = norDist.inverseCumulativeProbability(a);
|
27
29
|
|
@@ -33,6 +35,7 @@ public class LeftSideTest implements HypothTest {
|
|
33
35
|
|
34
36
|
return evaluation(statistic, l_val);
|
35
37
|
}
|
38
|
+
|
36
39
|
private boolean evaluation(double statistic, double l_val) {
|
37
40
|
boolean ret = true;
|
38
41
|
|
@@ -1,8 +1,10 @@
|
|
1
|
+
package hypothtst;
|
2
|
+
|
1
3
|
import org.apache.commons.math3.distribution.TDistribution;
|
2
4
|
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
3
5
|
import org.apache.commons.math3.distribution.NormalDistribution;
|
4
6
|
import org.apache.commons.math3.distribution.FDistribution;
|
5
|
-
|
7
|
+
// 片側検定(右側)
|
6
8
|
public class RightSideTest implements HypothTest {
|
7
9
|
private static HypothTest hupothTest = new RightSideTest();
|
8
10
|
public static HypothTest getInstance() {
|
@@ -20,7 +22,7 @@ public class RightSideTest implements HypothTest {
|
|
20
22
|
|
21
23
|
return evaluation(statistic, r_val);
|
22
24
|
}
|
23
|
-
public boolean
|
25
|
+
public boolean normDistTest(double statistic, double a) {
|
24
26
|
NormalDistribution norDist = new NormalDistribution(0, 1);
|
25
27
|
double r_val = norDist.inverseCumulativeProbability(1.0 - a);
|
26
28
|
|
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
package hypothtst;
|
2
|
+
|
2
3
|
import org.apache.commons.math3.distribution.TDistribution;
|
3
4
|
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
4
5
|
import org.apache.commons.math3.distribution.NormalDistribution;
|
5
6
|
import org.apache.commons.math3.distribution.FDistribution;
|
6
7
|
|
8
|
+
// 両側検定
|
7
9
|
public class TwoSideTest implements HypothTest {
|
8
10
|
private static HypothTest hupothTest = new TwoSideTest();
|
9
11
|
public static HypothTest getInstance() {
|
@@ -23,7 +25,7 @@ public class TwoSideTest implements HypothTest {
|
|
23
25
|
|
24
26
|
return evaluation(statistic, l_val, r_val);
|
25
27
|
}
|
26
|
-
public boolean
|
28
|
+
public boolean normDistTest(double statistic, double a) {
|
27
29
|
NormalDistribution norDist = new NormalDistribution(0, 1);
|
28
30
|
double l_val = norDist.inverseCumulativeProbability(a / 2.0);
|
29
31
|
double r_val = norDist.inverseCumulativeProbability(1.0 - a / 2.0);
|
data/lib/num4hypothtst.rb
CHANGED
@@ -2,9 +2,10 @@ require 'java'
|
|
2
2
|
require 'num4hypothtst.jar'
|
3
3
|
require 'commons-math3-3.6.1.jar'
|
4
4
|
|
5
|
-
java_import 'TwoSideTest'
|
6
|
-
java_import 'RightSideTest'
|
7
|
-
java_import 'LeftSideTest'
|
5
|
+
java_import 'hypothtst.TwoSideTest'
|
6
|
+
java_import 'hypothtst.RightSideTest'
|
7
|
+
java_import 'hypothtst.LeftSideTest'
|
8
|
+
java_import 'hypothtst.GrubbsTest'
|
8
9
|
|
9
10
|
# 統計的仮設検定のためのライブラリ
|
10
11
|
# (Apache commoms math3使用)
|
@@ -17,40 +18,40 @@ module Num4HypothTestLib
|
|
17
18
|
# T検定
|
18
19
|
#
|
19
20
|
# @overload tDistTest(statistic, df, a)
|
20
|
-
# @param [double] statistic
|
21
|
+
# @param [double] statistic 検定統計量
|
21
22
|
# @param [int] df 自由度
|
22
23
|
# @param [double] a 有意水準
|
23
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
24
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
24
25
|
def tDistTest(statistic, df, a)
|
25
26
|
return @hypothTest.tDistTest(statistic, df, a)
|
26
27
|
end
|
27
28
|
# 階2乗検定
|
28
29
|
#
|
29
30
|
# @overload chi2DistTest(statistic, df, a)
|
30
|
-
# @param [double] statistic
|
31
|
+
# @param [double] statistic 検定統計量
|
31
32
|
# @param [int] df 自由度
|
32
33
|
# @param [double] a 有意水準
|
33
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
34
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
34
35
|
def chi2DistTest(statistic, df, a)
|
35
36
|
return @hypothTest.chi2DistTest(statistic, df, a)
|
36
37
|
end
|
37
38
|
# 標準正規分布検定
|
38
39
|
#
|
39
|
-
# @overload
|
40
|
-
# @param [double] statistic
|
40
|
+
# @overload normDistTest(statistic, a)
|
41
|
+
# @param [double] statistic 検定統計量
|
41
42
|
# @param [double] a 有意水準
|
42
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
43
|
-
def
|
44
|
-
return @hypothTest.
|
43
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
44
|
+
def normDistTest(statistic, a)
|
45
|
+
return @hypothTest.normDistTest(statistic, a)
|
45
46
|
end
|
46
47
|
# F検定
|
47
48
|
#
|
48
49
|
# @overload fDistTest(statistic, nf, df, a)
|
49
|
-
# @param [double] statistic
|
50
|
+
# @param [double] statistic 検定統計量
|
50
51
|
# @param [int] nf 自由度
|
51
52
|
# @param [int] df 自由度
|
52
53
|
# @param [double] a 有意水準
|
53
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
54
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
54
55
|
def fDistTest(statistic, nf, df, a)
|
55
56
|
return @hypothTest.fDistTest(statistic, nf, df, a)
|
56
57
|
end
|
@@ -63,40 +64,40 @@ module Num4HypothTestLib
|
|
63
64
|
# T検定
|
64
65
|
#
|
65
66
|
# @overload tDistTest(statistic, df, a)
|
66
|
-
# @param [double] statistic
|
67
|
+
# @param [double] statistic 検定統計量
|
67
68
|
# @param [int] df 自由度
|
68
69
|
# @param [double] a 有意水準
|
69
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
70
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
70
71
|
def tDistTest(statistic, df, a)
|
71
72
|
return @hypothTest.tDistTest(statistic, df, a)
|
72
73
|
end
|
73
74
|
# 階2乗検定
|
74
75
|
#
|
75
76
|
# @overload chi2DistTest(statistic, df, a)
|
76
|
-
# @param [double] statistic
|
77
|
+
# @param [double] statistic 検定統計量
|
77
78
|
# @param [int] df 自由度
|
78
79
|
# @param [double] a 有意水準
|
79
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
80
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
80
81
|
def chi2DistTest(statistic, df, a)
|
81
82
|
return @hypothTest.chi2DistTest(statistic, df, a)
|
82
83
|
end
|
83
84
|
# 標準正規分布検定
|
84
85
|
#
|
85
|
-
# @overload
|
86
|
-
# @param [double] statistic
|
86
|
+
# @overload normDistTest(statistic, a)
|
87
|
+
# @param [double] statistic 検定統計量
|
87
88
|
# @param [double] a 有意水準
|
88
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
89
|
-
def
|
90
|
-
return @hypothTest.
|
89
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
90
|
+
def normDistTest(statistic, a)
|
91
|
+
return @hypothTest.normDistTest(statistic, a)
|
91
92
|
end
|
92
93
|
# F検定
|
93
94
|
#
|
94
95
|
# @overload fDistTest(statistic, nf, df, a)
|
95
|
-
# @param [double] statistic
|
96
|
+
# @param [double] statistic 検定統計量
|
96
97
|
# @param [int] nf 自由度
|
97
98
|
# @param [int] df 自由度
|
98
99
|
# @param [double] a 有意水準
|
99
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
100
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
100
101
|
def fDistTest(statistic, nf, df, a)
|
101
102
|
return @hypothTest.fDistTest(statistic, nf, df, a)
|
102
103
|
end
|
@@ -109,43 +110,69 @@ module Num4HypothTestLib
|
|
109
110
|
# T検定
|
110
111
|
#
|
111
112
|
# @overload tDistTest(statistic, df, a)
|
112
|
-
# @param [double] statistic
|
113
|
+
# @param [double] statistic 検定統計量
|
113
114
|
# @param [int] df 自由度
|
114
115
|
# @param [double] a 有意水準
|
115
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
116
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
116
117
|
def tDistTest(statistic, df, a)
|
117
118
|
return @hypothTest.tDistTest(statistic, df, a)
|
118
119
|
end
|
119
120
|
# 階2乗検定
|
120
121
|
#
|
121
122
|
# @overload chi2DistTest(statistic, df, a)
|
122
|
-
# @param [double] statistic
|
123
|
+
# @param [double] statistic 検定統計量
|
123
124
|
# @param [int] df 自由度
|
124
125
|
# @param [double] a 有意水準
|
125
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
126
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
126
127
|
def chi2DistTest(statistic, df, a)
|
127
128
|
return @hypothTest.chi2DistTest(statistic, df, a)
|
128
129
|
end
|
129
130
|
# 標準正規分布検定
|
130
131
|
#
|
131
|
-
# @overload
|
132
|
-
# @param [double] statistic
|
132
|
+
# @overload normDistTest(statistic, a)
|
133
|
+
# @param [double] statistic 検定統計量
|
133
134
|
# @param [double] a 有意水準
|
134
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
135
|
-
def
|
136
|
-
return @hypothTest.
|
135
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
136
|
+
def normDistTest(statistic, a)
|
137
|
+
return @hypothTest.normDistTest(statistic, a)
|
137
138
|
end
|
138
139
|
# F検定
|
139
140
|
#
|
140
141
|
# @overload fDistTest(statistic, nf, df, a)
|
141
|
-
# @param [double] statistic
|
142
|
+
# @param [double] statistic 検定統計量
|
142
143
|
# @param [int] nf 自由度
|
143
144
|
# @param [int] df 自由度
|
144
145
|
# @param [double] a 有意水準
|
145
|
-
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
146
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
146
147
|
def fDistTest(statistic, nf, df, a)
|
147
148
|
return @hypothTest.fDistTest(statistic, nf, df, a)
|
148
149
|
end
|
149
150
|
end
|
151
|
+
# グラブス・スミルノフの外れ値の検定
|
152
|
+
class GrubbsTestLib
|
153
|
+
def initialize
|
154
|
+
@hypothTest = GrubbsTest.getInstance()
|
155
|
+
end
|
156
|
+
# 両側検定
|
157
|
+
#
|
158
|
+
# @overload twoSideTest(statistic, n, a)
|
159
|
+
# @param [double] statistic 検定統計量
|
160
|
+
# @param [int] n 自由度
|
161
|
+
# @param [double] a 有意水準
|
162
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
163
|
+
def twoSideTest(statistic, n, a)
|
164
|
+
return @hypothTest.twoSideTest(statistic, n, a)
|
165
|
+
end
|
166
|
+
# 片側検定
|
167
|
+
#
|
168
|
+
# @overload oneSideTest(statistic, n, a)
|
169
|
+
# @param [double] statistic 検定統計量
|
170
|
+
# @param [int] n 自由度
|
171
|
+
# @param [double] a 有意水準
|
172
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
173
|
+
def oneSideTest(statistic, n, a)
|
174
|
+
return @hypothTest.oneSideTest(statistic, n, a)
|
175
|
+
end
|
176
|
+
end
|
150
177
|
end
|
151
178
|
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: num4hypothtst
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
14
15
|
requirement: !ruby/object:Gem::Requirement
|
15
16
|
requirements:
|
16
17
|
- - "~>"
|
@@ -19,9 +20,8 @@ dependencies:
|
|
19
20
|
- - ">="
|
20
21
|
- !ruby/object:Gem::Version
|
21
22
|
version: 12.3.3
|
22
|
-
name: rake
|
23
|
-
prerelease: false
|
24
23
|
type: :development
|
24
|
+
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
@@ -31,6 +31,7 @@ dependencies:
|
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 12.3.3
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake-compiler
|
34
35
|
requirement: !ruby/object:Gem::Requirement
|
35
36
|
requirements:
|
36
37
|
- - "~>"
|
@@ -39,9 +40,8 @@ dependencies:
|
|
39
40
|
- - ">="
|
40
41
|
- !ruby/object:Gem::Version
|
41
42
|
version: 1.2.5
|
42
|
-
name: rake-compiler
|
43
|
-
prerelease: false
|
44
43
|
type: :development
|
44
|
+
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
@@ -61,17 +61,18 @@ files:
|
|
61
61
|
- Gemfile
|
62
62
|
- LICENSE
|
63
63
|
- Rakefile
|
64
|
-
- ext/num4hypothtst/
|
65
|
-
- ext/num4hypothtst/
|
66
|
-
- ext/num4hypothtst/
|
67
|
-
- ext/num4hypothtst/
|
64
|
+
- ext/num4hypothtst/hypothtst/GrubbsTest.java
|
65
|
+
- ext/num4hypothtst/hypothtst/HypothTest.java
|
66
|
+
- ext/num4hypothtst/hypothtst/LeftSideTest.java
|
67
|
+
- ext/num4hypothtst/hypothtst/RightSideTest.java
|
68
|
+
- ext/num4hypothtst/hypothtst/TwoSideTest.java
|
68
69
|
- lib/commons-math3-3.6.1.jar
|
69
70
|
- lib/num4hypothtst.rb
|
70
71
|
homepage: http://github.com/siranovel/num4hypothtst
|
71
72
|
licenses:
|
72
73
|
- MIT
|
73
74
|
metadata: {}
|
74
|
-
post_install_message:
|
75
|
+
post_install_message:
|
75
76
|
rdoc_options: []
|
76
77
|
require_paths:
|
77
78
|
- lib
|
@@ -86,8 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
86
87
|
- !ruby/object:Gem::Version
|
87
88
|
version: '0'
|
88
89
|
requirements: []
|
89
|
-
rubygems_version: 3.3.
|
90
|
-
signing_key:
|
90
|
+
rubygems_version: 3.3.7
|
91
|
+
signing_key:
|
91
92
|
specification_version: 4
|
92
93
|
summary: num for statistical test
|
93
94
|
test_files: []
|