num4hypothtst 0.0.1-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +9 -0
- data/Gemfile +3 -0
- data/LICENSE +21 -0
- data/Rakefile +7 -0
- data/ext/num4hypothtst/HypothTest.java +8 -0
- data/ext/num4hypothtst/LeftSideTest.java +46 -0
- data/ext/num4hypothtst/RightSideTest.java +44 -0
- data/ext/num4hypothtst/TwoSideTest.java +50 -0
- data/lib/commons-math3-3.6.1.jar +0 -0
- data/lib/num4hypothtst.rb +151 -0
- metadata +93 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3925064927f98f2485a8575a6f985ef3a94cf145c01c0fb5df4fd7425adecd41
|
4
|
+
data.tar.gz: cb9360b2ef3ea2b25b727ad8f492333b20fc27cb8e0ee0ecbada1a042256c803
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: df9b8af3355bdfd149138267257cba6234ead04c632c0764a2aeb0680136655db9083042b72795f818f2e8b8aa482288c6c504cc37f3e398d81db9ded96e8460
|
7
|
+
data.tar.gz: e72a23ec95a60fde1aa12ff66a4cafcf1741efebd5f3cabe412e2cdd311662160042adc3c864231c70d0ded2df35b5600678dc433aed3c0acc02ade49857b5ac
|
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2023 siranovel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
// 仮設検定
|
2
|
+
interface HypothTest {
|
3
|
+
boolean tDistTest(double statistic, double df, double a);
|
4
|
+
boolean chi2DistTest(double statistic, double df, double a);
|
5
|
+
boolean normDistest(double statistic, double a);
|
6
|
+
boolean fDistTest(double statistic, double nf, double df, double a);
|
7
|
+
}
|
8
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
// 片側検定(左側)
|
2
|
+
import org.apache.commons.math3.distribution.TDistribution;
|
3
|
+
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
4
|
+
import org.apache.commons.math3.distribution.NormalDistribution;
|
5
|
+
import org.apache.commons.math3.distribution.FDistribution;
|
6
|
+
|
7
|
+
public class LeftSideTest implements HypothTest {
|
8
|
+
private static HypothTest hupothTest = new LeftSideTest();
|
9
|
+
public static HypothTest getInstance() {
|
10
|
+
return hupothTest;
|
11
|
+
}
|
12
|
+
public boolean tDistTest(double statistic, double df, double a) {
|
13
|
+
TDistribution tDist = new TDistribution(df);
|
14
|
+
double l_val = tDist.inverseCumulativeProbability(a);
|
15
|
+
|
16
|
+
return evaluation(statistic, l_val);
|
17
|
+
}
|
18
|
+
public boolean chi2DistTest(double statistic, double df, double a) {
|
19
|
+
ChiSquaredDistribution chi2Dist = new ChiSquaredDistribution(df);
|
20
|
+
double l_val = chi2Dist.inverseCumulativeProbability(a);
|
21
|
+
|
22
|
+
return evaluation(statistic, l_val);
|
23
|
+
}
|
24
|
+
public boolean normDistest(double statistic, double a) {
|
25
|
+
NormalDistribution norDist = new NormalDistribution(0, 1);
|
26
|
+
double l_val = norDist.inverseCumulativeProbability(a);
|
27
|
+
|
28
|
+
return evaluation(statistic, l_val);
|
29
|
+
}
|
30
|
+
public boolean fDistTest(double statistic, double nf, double df, double a) {
|
31
|
+
FDistribution fDist = new FDistribution(nf, df);
|
32
|
+
double l_val = fDist.inverseCumulativeProbability(a);
|
33
|
+
|
34
|
+
return evaluation(statistic, l_val);
|
35
|
+
}
|
36
|
+
private boolean evaluation(double statistic, double l_val) {
|
37
|
+
boolean ret = true;
|
38
|
+
|
39
|
+
if (l_val < statistic) {
|
40
|
+
ret = false;
|
41
|
+
}
|
42
|
+
return ret;
|
43
|
+
}
|
44
|
+
|
45
|
+
}
|
46
|
+
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import org.apache.commons.math3.distribution.TDistribution;
|
2
|
+
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
3
|
+
import org.apache.commons.math3.distribution.NormalDistribution;
|
4
|
+
import org.apache.commons.math3.distribution.FDistribution;
|
5
|
+
|
6
|
+
public class RightSideTest implements HypothTest {
|
7
|
+
private static HypothTest hupothTest = new RightSideTest();
|
8
|
+
public static HypothTest getInstance() {
|
9
|
+
return hupothTest;
|
10
|
+
}
|
11
|
+
public boolean tDistTest(double statistic, double df, double a) {
|
12
|
+
TDistribution tDist = new TDistribution(df);
|
13
|
+
double r_val = tDist.inverseCumulativeProbability(1.0 - a);
|
14
|
+
|
15
|
+
return evaluation(statistic, r_val);
|
16
|
+
}
|
17
|
+
public boolean chi2DistTest(double statistic, double df, double a) {
|
18
|
+
ChiSquaredDistribution chi2Dist = new ChiSquaredDistribution(df);
|
19
|
+
double r_val = chi2Dist.inverseCumulativeProbability(1.0 - a);
|
20
|
+
|
21
|
+
return evaluation(statistic, r_val);
|
22
|
+
}
|
23
|
+
public boolean normDistest(double statistic, double a) {
|
24
|
+
NormalDistribution norDist = new NormalDistribution(0, 1);
|
25
|
+
double r_val = norDist.inverseCumulativeProbability(1.0 - a);
|
26
|
+
|
27
|
+
return evaluation(statistic, r_val);
|
28
|
+
}
|
29
|
+
public boolean fDistTest(double statistic, double nf, double df, double a) {
|
30
|
+
FDistribution fDist = new FDistribution(nf, df);
|
31
|
+
double r_val = fDist.inverseCumulativeProbability(1.0 - a);
|
32
|
+
|
33
|
+
return evaluation(statistic, r_val);
|
34
|
+
}
|
35
|
+
private boolean evaluation(double statistic, double r_val) {
|
36
|
+
boolean ret = true;
|
37
|
+
|
38
|
+
if (statistic < r_val) {
|
39
|
+
ret = false;
|
40
|
+
}
|
41
|
+
return ret;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
@@ -0,0 +1,50 @@
|
|
1
|
+
// 両側検定
|
2
|
+
import org.apache.commons.math3.distribution.TDistribution;
|
3
|
+
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
4
|
+
import org.apache.commons.math3.distribution.NormalDistribution;
|
5
|
+
import org.apache.commons.math3.distribution.FDistribution;
|
6
|
+
|
7
|
+
public class TwoSideTest implements HypothTest {
|
8
|
+
private static HypothTest hupothTest = new TwoSideTest();
|
9
|
+
public static HypothTest getInstance() {
|
10
|
+
return hupothTest;
|
11
|
+
}
|
12
|
+
public boolean tDistTest(double statistic, double df, double a) {
|
13
|
+
TDistribution tDist = new TDistribution(df);
|
14
|
+
double l_val = tDist.inverseCumulativeProbability(a / 2.0);
|
15
|
+
double r_val = tDist.inverseCumulativeProbability(1.0 - a / 2.0);
|
16
|
+
|
17
|
+
return evaluation(statistic, l_val, r_val);
|
18
|
+
}
|
19
|
+
public boolean chi2DistTest(double statistic, double df, double a) {
|
20
|
+
ChiSquaredDistribution chi2Dist = new ChiSquaredDistribution(df);
|
21
|
+
double l_val = chi2Dist.inverseCumulativeProbability(a / 2.0);
|
22
|
+
double r_val = chi2Dist.inverseCumulativeProbability(1.0 - a / 2.0);
|
23
|
+
|
24
|
+
return evaluation(statistic, l_val, r_val);
|
25
|
+
}
|
26
|
+
public boolean normDistest(double statistic, double a) {
|
27
|
+
NormalDistribution norDist = new NormalDistribution(0, 1);
|
28
|
+
double l_val = norDist.inverseCumulativeProbability(a / 2.0);
|
29
|
+
double r_val = norDist.inverseCumulativeProbability(1.0 - a / 2.0);
|
30
|
+
|
31
|
+
return evaluation(statistic, l_val, r_val);
|
32
|
+
}
|
33
|
+
public boolean fDistTest(double statistic, double nf, double df, double a) {
|
34
|
+
FDistribution fDist = new FDistribution(nf, df);
|
35
|
+
double l_val = fDist.inverseCumulativeProbability(a / 2.0);
|
36
|
+
double r_val = fDist.inverseCumulativeProbability(1.0 - a / 2.0);
|
37
|
+
|
38
|
+
return evaluation(statistic, l_val, r_val);
|
39
|
+
}
|
40
|
+
private boolean evaluation(double statistic, double l_val, double r_val) {
|
41
|
+
boolean ret = true;
|
42
|
+
|
43
|
+
if ((l_val < statistic) && (statistic < r_val)) {
|
44
|
+
ret = false;
|
45
|
+
}
|
46
|
+
return ret;
|
47
|
+
}
|
48
|
+
|
49
|
+
}
|
50
|
+
|
Binary file
|
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'java'
|
2
|
+
require 'num4hypothtst.jar'
|
3
|
+
require 'commons-math3-3.6.1.jar'
|
4
|
+
|
5
|
+
java_import 'TwoSideTest'
|
6
|
+
java_import 'RightSideTest'
|
7
|
+
java_import 'LeftSideTest'
|
8
|
+
|
9
|
+
# 統計的仮設検定のためのライブラリ
|
10
|
+
# (Apache commoms math3使用)
|
11
|
+
module Num4HypothTestLib
|
12
|
+
# 両側検定
|
13
|
+
class TwoSideTestLib
|
14
|
+
def initialize
|
15
|
+
@hypothTest = TwoSideTest.getInstance()
|
16
|
+
end
|
17
|
+
# T検定
|
18
|
+
#
|
19
|
+
# @overload tDistTest(statistic, df, a)
|
20
|
+
# @param [double] statistic 統計量
|
21
|
+
# @param [int] df 自由度
|
22
|
+
# @param [double] a 有意水準
|
23
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
24
|
+
def tDistTest(statistic, df, a)
|
25
|
+
return @hypothTest.tDistTest(statistic, df, a)
|
26
|
+
end
|
27
|
+
# 階2乗検定
|
28
|
+
#
|
29
|
+
# @overload chi2DistTest(statistic, df, a)
|
30
|
+
# @param [double] statistic 統計量
|
31
|
+
# @param [int] df 自由度
|
32
|
+
# @param [double] a 有意水準
|
33
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
34
|
+
def chi2DistTest(statistic, df, a)
|
35
|
+
return @hypothTest.chi2DistTest(statistic, df, a)
|
36
|
+
end
|
37
|
+
# 標準正規分布検定
|
38
|
+
#
|
39
|
+
# @overload normDistest(statistic, a)
|
40
|
+
# @param [double] statistic 統計量
|
41
|
+
# @param [double] a 有意水準
|
42
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
43
|
+
def normDistest(statistic, a)
|
44
|
+
return @hypothTest.normDistest(statistic, a)
|
45
|
+
end
|
46
|
+
# F検定
|
47
|
+
#
|
48
|
+
# @overload fDistTest(statistic, nf, df, a)
|
49
|
+
# @param [double] statistic 統計量
|
50
|
+
# @param [int] nf 自由度
|
51
|
+
# @param [int] df 自由度
|
52
|
+
# @param [double] a 有意水準
|
53
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
54
|
+
def fDistTest(statistic, nf, df, a)
|
55
|
+
return @hypothTest.fDistTest(statistic, nf, df, a)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
# 片側(右側)検定
|
59
|
+
class RightSideTestLib
|
60
|
+
def initialize
|
61
|
+
@hypothTest = RightSideTest.getInstance()
|
62
|
+
end
|
63
|
+
# T検定
|
64
|
+
#
|
65
|
+
# @overload tDistTest(statistic, df, a)
|
66
|
+
# @param [double] statistic 統計量
|
67
|
+
# @param [int] df 自由度
|
68
|
+
# @param [double] a 有意水準
|
69
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
70
|
+
def tDistTest(statistic, df, a)
|
71
|
+
return @hypothTest.tDistTest(statistic, df, a)
|
72
|
+
end
|
73
|
+
# 階2乗検定
|
74
|
+
#
|
75
|
+
# @overload chi2DistTest(statistic, df, a)
|
76
|
+
# @param [double] statistic 統計量
|
77
|
+
# @param [int] df 自由度
|
78
|
+
# @param [double] a 有意水準
|
79
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
80
|
+
def chi2DistTest(statistic, df, a)
|
81
|
+
return @hypothTest.chi2DistTest(statistic, df, a)
|
82
|
+
end
|
83
|
+
# 標準正規分布検定
|
84
|
+
#
|
85
|
+
# @overload normDistest(statistic, a)
|
86
|
+
# @param [double] statistic 統計量
|
87
|
+
# @param [double] a 有意水準
|
88
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
89
|
+
def normDistest(statistic, a)
|
90
|
+
return @hypothTest.normDistest(statistic, a)
|
91
|
+
end
|
92
|
+
# F検定
|
93
|
+
#
|
94
|
+
# @overload fDistTest(statistic, nf, df, a)
|
95
|
+
# @param [double] statistic 統計量
|
96
|
+
# @param [int] nf 自由度
|
97
|
+
# @param [int] df 自由度
|
98
|
+
# @param [double] a 有意水準
|
99
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
100
|
+
def fDistTest(statistic, nf, df, a)
|
101
|
+
return @hypothTest.fDistTest(statistic, nf, df, a)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
# 片側(左側)検定
|
105
|
+
class LeftSideTestLib
|
106
|
+
def initialize
|
107
|
+
@hypothTest = LeftSideTest.getInstance()
|
108
|
+
end
|
109
|
+
# T検定
|
110
|
+
#
|
111
|
+
# @overload tDistTest(statistic, df, a)
|
112
|
+
# @param [double] statistic 統計量
|
113
|
+
# @param [int] df 自由度
|
114
|
+
# @param [double] a 有意水準
|
115
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
116
|
+
def tDistTest(statistic, df, a)
|
117
|
+
return @hypothTest.tDistTest(statistic, df, a)
|
118
|
+
end
|
119
|
+
# 階2乗検定
|
120
|
+
#
|
121
|
+
# @overload chi2DistTest(statistic, df, a)
|
122
|
+
# @param [double] statistic 統計量
|
123
|
+
# @param [int] df 自由度
|
124
|
+
# @param [double] a 有意水準
|
125
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
126
|
+
def chi2DistTest(statistic, df, a)
|
127
|
+
return @hypothTest.chi2DistTest(statistic, df, a)
|
128
|
+
end
|
129
|
+
# 標準正規分布検定
|
130
|
+
#
|
131
|
+
# @overload normDistest(statistic, a)
|
132
|
+
# @param [double] statistic 統計量
|
133
|
+
# @param [double] a 有意水準
|
134
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
135
|
+
def normDistest(statistic, a)
|
136
|
+
return @hypothTest.normDistest(statistic, a)
|
137
|
+
end
|
138
|
+
# F検定
|
139
|
+
#
|
140
|
+
# @overload fDistTest(statistic, nf, df, a)
|
141
|
+
# @param [double] statistic 統計量
|
142
|
+
# @param [int] nf 自由度
|
143
|
+
# @param [int] df 自由度
|
144
|
+
# @param [double] a 有意水準
|
145
|
+
# return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
146
|
+
def fDistTest(statistic, nf, df, a)
|
147
|
+
return @hypothTest.fDistTest(statistic, nf, df, a)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: num4hypothtst
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: java
|
6
|
+
authors:
|
7
|
+
- siranovel
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-10-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '12.3'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 12.3.3
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '12.3'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 12.3.3
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: rake-compiler
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '1.2'
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: 1.2.5
|
43
|
+
type: :development
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - "~>"
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '1.2'
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: 1.2.5
|
53
|
+
description: num for test of statistical hypothesis!
|
54
|
+
email: siranovel@gmail.com
|
55
|
+
executables: []
|
56
|
+
extensions:
|
57
|
+
- Rakefile
|
58
|
+
extra_rdoc_files: []
|
59
|
+
files:
|
60
|
+
- CHANGELOG.md
|
61
|
+
- Gemfile
|
62
|
+
- LICENSE
|
63
|
+
- Rakefile
|
64
|
+
- ext/num4hypothtst/HypothTest.java
|
65
|
+
- ext/num4hypothtst/LeftSideTest.java
|
66
|
+
- ext/num4hypothtst/RightSideTest.java
|
67
|
+
- ext/num4hypothtst/TwoSideTest.java
|
68
|
+
- lib/commons-math3-3.6.1.jar
|
69
|
+
- lib/num4hypothtst.rb
|
70
|
+
homepage: http://github.com/siranovel/stdy4act
|
71
|
+
licenses:
|
72
|
+
- MIT
|
73
|
+
metadata: {}
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
require_paths:
|
77
|
+
- lib
|
78
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
requirements: []
|
89
|
+
rubygems_version: 3.3.7
|
90
|
+
signing_key:
|
91
|
+
specification_version: 4
|
92
|
+
summary: num for statistical test
|
93
|
+
test_files: []
|