num4hypothtst 0.0.3-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 +5 -0
- data/ext/num4hypothtst/hypothtst/GrubbsTest.java +34 -0
- data/ext/num4hypothtst/{HypothTest.java → hypothtst/HypothTest.java} +2 -1
- data/ext/num4hypothtst/{LeftSideTest.java → hypothtst/LeftSideTest.java} +3 -4
- data/ext/num4hypothtst/{RightSideTest.java → hypothtst/RightSideTest.java} +3 -12
- data/ext/num4hypothtst/{TwoSideTest.java → hypothtst/TwoSideTest.java} +3 -20
- data/lib/num4hypothtst.rb +30 -23
- metadata +7 -6
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
@@ -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,9 +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
7
|
boolean normDistTest(double statistic, double a);
|
6
8
|
boolean fDistTest(double statistic, double nf, double df, double a);
|
7
|
-
boolean gnTest(double statistic, int n, double a);
|
8
9
|
}
|
9
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() {
|
@@ -33,9 +35,6 @@ public class LeftSideTest implements HypothTest {
|
|
33
35
|
|
34
36
|
return evaluation(statistic, l_val);
|
35
37
|
}
|
36
|
-
public boolean gnTest(double statistic, int n, double a) {
|
37
|
-
return false;
|
38
|
-
}
|
39
38
|
|
40
39
|
private boolean evaluation(double statistic, double l_val) {
|
41
40
|
boolean ret = true;
|
@@ -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() {
|
@@ -32,17 +34,6 @@ public class RightSideTest implements HypothTest {
|
|
32
34
|
|
33
35
|
return evaluation(statistic, r_val);
|
34
36
|
}
|
35
|
-
public boolean gnTest(double statistic, int n, double a) {
|
36
|
-
double r_val = calcGnValue(n, a);
|
37
|
-
return evaluation(statistic, r_val);
|
38
|
-
}
|
39
|
-
private double calcGnValue(int n, double a) {
|
40
|
-
TDistribution tDist = new TDistribution(n);
|
41
|
-
double t = tDist.inverseCumulativeProbability(a / n);
|
42
|
-
double gn = (n - 1) * t / Math.sqrt(n * (n - 2 + t * t));
|
43
|
-
|
44
|
-
return Math.abs(gn);
|
45
|
-
}
|
46
37
|
private boolean evaluation(double statistic, double r_val) {
|
47
38
|
boolean ret = true;
|
48
39
|
|
@@ -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() {
|
@@ -37,17 +39,6 @@ public class TwoSideTest implements HypothTest {
|
|
37
39
|
|
38
40
|
return evaluation(statistic, l_val, r_val);
|
39
41
|
}
|
40
|
-
public boolean gnTest(double statistic, int n, double a) {
|
41
|
-
double r_val = calcGnValue(n, a / 2.0);
|
42
|
-
return evaluation(statistic, r_val);
|
43
|
-
}
|
44
|
-
private double calcGnValue(int n, double a) {
|
45
|
-
TDistribution tDist = new TDistribution(n);
|
46
|
-
double t = tDist.inverseCumulativeProbability(a / n);
|
47
|
-
double gn = (n - 1) * t / Math.sqrt(n * (n - 2 + t * t));
|
48
|
-
|
49
|
-
return Math.abs(gn);
|
50
|
-
}
|
51
42
|
private boolean evaluation(double statistic, double l_val, double r_val) {
|
52
43
|
boolean ret = true;
|
53
44
|
|
@@ -56,14 +47,6 @@ public class TwoSideTest implements HypothTest {
|
|
56
47
|
}
|
57
48
|
return ret;
|
58
49
|
}
|
59
|
-
private boolean evaluation(double statistic, double r_val) {
|
60
|
-
boolean ret = true;
|
61
|
-
|
62
|
-
if (Math.abs(statistic) < r_val) {
|
63
|
-
ret = false;
|
64
|
-
}
|
65
|
-
return ret;
|
66
|
-
}
|
67
50
|
|
68
51
|
}
|
69
52
|
|
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使用)
|
@@ -54,16 +55,6 @@ module Num4HypothTestLib
|
|
54
55
|
def fDistTest(statistic, nf, df, a)
|
55
56
|
return @hypothTest.fDistTest(statistic, nf, df, a)
|
56
57
|
end
|
57
|
-
# グラブス・スミルノフの外れ値の検定
|
58
|
-
#
|
59
|
-
# @overload gnTest(statistic, n, a)
|
60
|
-
# @param [double] statistic 検定統計量
|
61
|
-
# @param [int] n 自由度
|
62
|
-
# @param [double] a 有意水準
|
63
|
-
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
64
|
-
def gnTest(statistic, n, a)
|
65
|
-
return @hypothTest.gnTest(statistic, n, a)
|
66
|
-
end
|
67
58
|
end
|
68
59
|
# 片側(右側)検定
|
69
60
|
class RightSideTestLib
|
@@ -110,16 +101,6 @@ module Num4HypothTestLib
|
|
110
101
|
def fDistTest(statistic, nf, df, a)
|
111
102
|
return @hypothTest.fDistTest(statistic, nf, df, a)
|
112
103
|
end
|
113
|
-
# グラブス・スミルノフの外れ値の検定
|
114
|
-
#
|
115
|
-
# @overload gnTest(statistic, n, a)
|
116
|
-
# @param [double] statistic 検定統計量
|
117
|
-
# @param [int] n 自由度
|
118
|
-
# @param [double] a 有意水準
|
119
|
-
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
120
|
-
def gnTest(statistic, n, a)
|
121
|
-
return @hypothTest.gnTest(statistic, n, a)
|
122
|
-
end
|
123
104
|
end
|
124
105
|
# 片側(左側)検定
|
125
106
|
class LeftSideTestLib
|
@@ -167,5 +148,31 @@ module Num4HypothTestLib
|
|
167
148
|
return @hypothTest.fDistTest(statistic, nf, df, a)
|
168
149
|
end
|
169
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
|
170
177
|
end
|
171
178
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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
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
14
|
name: rake
|
@@ -61,10 +61,11 @@ 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
|