num4tststatistic2 0.0.1 → 0.0.2
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 +4 -4
- data/CHANGELOG.md +7 -1
- data/Gemfile +3 -2
- data/lib/num4tststatistic2.rb +42 -19
- 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: 1cde00758d2f1f56ba425ce885da276d76272564848fd176dc78ab7e271ffdc5
|
4
|
+
data.tar.gz: c0631d73f042ab0bc7be1be74f408cc298cf0237a6ad56c7b9342edfbf8ef807
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80815f8945e899f8699bb3d06a27abc41c8b00967ab9f2b6b0badb2540c19a13f123f8a376c05358f277cc10c6947e6c4b028a5738d91b3f38002f6f614fd410
|
7
|
+
data.tar.gz: bd512533a00f76c4e6ed738c25bfb6cc61af2c634d5b28dac6236844e03e15088e5a846acead538b4dd8e1e4e38d99b258b5bc945fe68912f96999a519842374
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/lib/num4tststatistic2.rb
CHANGED
@@ -16,12 +16,14 @@ module Num4TstStatistic2Lib
|
|
16
16
|
# @param [double] a 有意水準
|
17
17
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
18
18
|
# @example
|
19
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
20
19
|
# xi = [15.5, 15.7, 15.4, 15.4, 15.6, 15.4, 15.6, 15.5, 15.4]
|
21
|
-
#
|
20
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
21
|
+
# paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
|
22
22
|
# paraTest.populationMean(xi, 15.4, 0.05)
|
23
23
|
# => true
|
24
24
|
def populationMean(xi, m0, a)
|
25
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
26
|
+
|
25
27
|
df = xi.size - 1
|
26
28
|
statistic = @paraTest.populationMean(xi, m0)
|
27
29
|
return @hypothTest3.tDistTest(statistic, df, a)
|
@@ -41,11 +43,13 @@ module Num4TstStatistic2Lib
|
|
41
43
|
# paraTest.populationVar(xi, sd*sd, 0.05)
|
42
44
|
# => true
|
43
45
|
def populationVar(xi, sig0, a)
|
46
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
47
|
+
|
44
48
|
df = xi.size - 1
|
45
49
|
statistic = @paraTest.populationVar(xi, sig0)
|
46
50
|
return @hypothTest3.chi2DistTest(statistic, df, a)
|
47
51
|
end
|
48
|
-
#
|
52
|
+
# 母比率の検定
|
49
53
|
#
|
50
54
|
# @overload populationRatio(m, n, p0, a)
|
51
55
|
# @param [int] m m値
|
@@ -59,11 +63,12 @@ module Num4TstStatistic2Lib
|
|
59
63
|
# paraTest.populationRatio(29, 346, 0.12, 0.05)
|
60
64
|
# => true
|
61
65
|
def populationRatio(m, n, p0, a)
|
66
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
67
|
+
|
62
68
|
statistic = @paraTest.populationRatio(m, n, p0)
|
63
69
|
return @hypothTest3.normDistTest(statistic, a)
|
64
70
|
end
|
65
|
-
# 2
|
66
|
-
# (等分散性を仮定)
|
71
|
+
# 2つの母平均の差の検定(等分散性を仮定)
|
67
72
|
#
|
68
73
|
# @overload diffPopulationMean2EquVar(xi1, xi2, a)
|
69
74
|
# @param [Array] xi1 x1のデータ(double[])
|
@@ -78,14 +83,15 @@ module Num4TstStatistic2Lib
|
|
78
83
|
# paraTest.diffPopulationMean2EquVar(xi1, xi2, 0.05)
|
79
84
|
# => false
|
80
85
|
def diffPopulationMean2EquVar(xi1, xi2, a)
|
86
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
87
|
+
|
81
88
|
n1 = xi1.size
|
82
89
|
n2 = xi2.size
|
83
90
|
df = n1 + n2 - 2
|
84
91
|
statistic = @paraTest.diffPopulationMean2EquVar(xi1, xi2)
|
85
92
|
return @hypothTest3.tDistTest(statistic, df, a)
|
86
93
|
end
|
87
|
-
# 2
|
88
|
-
# (不等分散性を仮定)
|
94
|
+
# 2つの母平均の差の検定(不等分散性を仮定)
|
89
95
|
#
|
90
96
|
# @overload diffPopulationMean2UnEquVar(xi1, xi2, a)
|
91
97
|
# @param [Array] xi1 x1のデータ(double[])
|
@@ -100,6 +106,8 @@ module Num4TstStatistic2Lib
|
|
100
106
|
# paraTest.diffPopulationMean2UnEquVar(xi1, xi2, 0.05)
|
101
107
|
# => false
|
102
108
|
def diffPopulationMean2UnEquVar(xi1, xi2, a)
|
109
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
110
|
+
|
103
111
|
df = @paraTest.df4welch(xi1, xi2)
|
104
112
|
statistic = @paraTest.diffPopulationMean2UnEquVar(xi1, xi2)
|
105
113
|
return @hypothTest3.tDistTest(statistic, df, a)
|
@@ -119,12 +127,14 @@ module Num4TstStatistic2Lib
|
|
119
127
|
# paraTest.diffPopulationMean(xi1, xi2, 0.05)
|
120
128
|
# => true
|
121
129
|
def diffPopulationMean(xi1, xi2, a)
|
130
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
131
|
+
|
122
132
|
n = xi1.size
|
123
133
|
df = n - 1
|
124
134
|
statistic = @paraTest.diffPopulationMean(xi1, xi2)
|
125
135
|
return @hypothTest3.tDistTest(statistic, df, a)
|
126
136
|
end
|
127
|
-
# 2
|
137
|
+
# 2つの母分散の差の検定
|
128
138
|
#
|
129
139
|
# @overload diffPopulationVar(xi1, xi2, a)
|
130
140
|
# @param [Array] xi1 x1のデータ(double[])
|
@@ -139,12 +149,14 @@ module Num4TstStatistic2Lib
|
|
139
149
|
# paraTest.diffPopulationVar(xi1, xi2, 0.05)
|
140
150
|
# => false
|
141
151
|
def diffPopulationVar(xi1, xi2, a)
|
152
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
153
|
+
|
142
154
|
nf = xi1.size - 1
|
143
155
|
df = xi2.size - 1
|
144
156
|
statistic = @paraTest.diffPopulationVar(xi1, xi2)
|
145
157
|
return @hypothTest3.fDistTest(statistic, nf, df, a)
|
146
158
|
end
|
147
|
-
# 2
|
159
|
+
# 2つの母比率の差の検定
|
148
160
|
#
|
149
161
|
# @overload diffPopulationRatio(m1, n1, m2, n2, a)
|
150
162
|
# @param [int] m1 m1値
|
@@ -159,10 +171,12 @@ module Num4TstStatistic2Lib
|
|
159
171
|
# paraTest.diffPopulationRatio(469, 1200, 308, 900, 0.05)
|
160
172
|
# => true
|
161
173
|
def diffPopulationRatio(m1, n1, m2, n2, a)
|
174
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
175
|
+
|
162
176
|
statistic = @paraTest.diffPopulationRatio(m1, n1, m2, n2)
|
163
177
|
return @hypothTest3.normDistTest(statistic, a)
|
164
178
|
end
|
165
|
-
#
|
179
|
+
# 適合度の検定
|
166
180
|
#
|
167
181
|
# @overload fidelity(fi, pi, a)
|
168
182
|
# @param [Array] fi 実測度数(double[])
|
@@ -177,11 +191,13 @@ module Num4TstStatistic2Lib
|
|
177
191
|
# paraTest.fidelity(fi, pi, 0.05)
|
178
192
|
# => false
|
179
193
|
def fidelity(fi, pi, a)
|
194
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
195
|
+
|
180
196
|
df = fi.size - 1
|
181
197
|
statistic = @paraTest.fidelity(fi, pi)
|
182
198
|
return @hypothTest3.chi2DistTest(statistic, df, a)
|
183
199
|
end
|
184
|
-
#
|
200
|
+
# 独立性の検定
|
185
201
|
#
|
186
202
|
# @overload independency(fij, a)
|
187
203
|
# @param [Array] fij 実測度数(double[][])
|
@@ -197,6 +213,8 @@ module Num4TstStatistic2Lib
|
|
197
213
|
# paraTest.independency(fij, 0.05)
|
198
214
|
# => true
|
199
215
|
def independency(fij, a)
|
216
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
217
|
+
|
200
218
|
m = fij.size
|
201
219
|
n = fij[0].size
|
202
220
|
df = (m - 1) * (n - 1)
|
@@ -217,13 +235,15 @@ module Num4TstStatistic2Lib
|
|
217
235
|
# @param [double] a 有意水準
|
218
236
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
219
237
|
# @example
|
220
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
221
238
|
# x = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
|
222
239
|
# y = [180, 180, 235, 270, 240, 285, 164, 152]
|
240
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
223
241
|
# nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
|
224
242
|
# nonParaTest.utest(x, y, 0.05)
|
225
243
|
# => true
|
226
244
|
def utest(x, y, a)
|
245
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
246
|
+
|
227
247
|
statistic = @nonParaTest.utest(x, y)
|
228
248
|
return @hypothTest3.normDistTest(statistic, a)
|
229
249
|
end
|
@@ -235,13 +255,15 @@ module Num4TstStatistic2Lib
|
|
235
255
|
# @param [double] a 有意水準
|
236
256
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
237
257
|
# @example
|
238
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
239
258
|
# x = [37.1, 36.2, 36.6, 37.4, 36.8, 36.7, 36.9, 37.4, 36.6, 36.7]
|
240
259
|
# y = [36.8, 36.6, 36.5, 37.0, 36.0, 36.5, 36.6, 37.1, 36.4, 36.7]
|
260
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
241
261
|
# nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
|
242
262
|
# nonParaTest.wilcoxon(x, y, 0.05)
|
243
263
|
# => true
|
244
264
|
def wilcoxon(x, y, a)
|
265
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
266
|
+
|
245
267
|
statistic = @nonParaTest.wilcoxon(x, y)
|
246
268
|
return @hypothTest3.normDistTest(statistic, a)
|
247
269
|
end
|
@@ -253,13 +275,15 @@ module Num4TstStatistic2Lib
|
|
253
275
|
# @param [double] a 有意水準
|
254
276
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
255
277
|
# @example
|
256
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
257
278
|
# xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
|
258
279
|
# xi2 = [180, 180, 235, 270, 240, 285, 164, 152]
|
259
|
-
#
|
280
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
281
|
+
# nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
|
260
282
|
# nonParaTest.ks2test(xi1, xi2, 0.05)
|
261
283
|
# => false
|
262
284
|
def ks2test(xi1, xi2, a)
|
285
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
286
|
+
|
263
287
|
return @nonParaTest.ks2test(xi1, xi2, a)
|
264
288
|
end
|
265
289
|
end
|
@@ -268,7 +292,7 @@ module Num4TstStatistic2Lib
|
|
268
292
|
@outlier = Num4TstStatisticLib::OutlierLib.new
|
269
293
|
@hypothTest2 = Num4HypothTestLib::GrubbsTestLib.new
|
270
294
|
end
|
271
|
-
#
|
295
|
+
# グラプス・スミルノフの外れ値の検定
|
272
296
|
#
|
273
297
|
# @overload grubbs(xi, xk, a)
|
274
298
|
# @param [Array] xi xiのデータ(double[])
|
@@ -276,7 +300,7 @@ module Num4TstStatistic2Lib
|
|
276
300
|
# @return [double] 検定統計量
|
277
301
|
# @example
|
278
302
|
# xi = [3.4, 3.5, 3.3, 2.2, 3.3, 3.4, 3.6, 3.2]
|
279
|
-
# outlier =
|
303
|
+
# outlier = Num4TstStatistic2Lib::OutlierLib.new
|
280
304
|
# outlier.grubbs(xi, 2.2, 0.05)
|
281
305
|
# => true
|
282
306
|
def grubbs(xi, xk, a)
|
@@ -292,7 +316,7 @@ module Num4TstStatistic2Lib
|
|
292
316
|
# @return [void] errbar.jpegファイルを出力
|
293
317
|
# @example
|
294
318
|
# xi = [3.4, 3.5, 3.3, 2.2, 3.3, 3.4, 3.6, 3.2]
|
295
|
-
# outlier =
|
319
|
+
# outlier = Num4TstStatistic2Lib::OutlierLib.new
|
296
320
|
# outlier.grubbs("LDH", xi)
|
297
321
|
# => errbar.jpeg
|
298
322
|
def errbar(dname, xi)
|
@@ -307,7 +331,6 @@ module Num4TstStatistic2Lib
|
|
307
331
|
@hypothTest = Num4HypothTestLib::DecorrTestLib.new
|
308
332
|
end
|
309
333
|
# ピアソン相関係数
|
310
|
-
# (相関係数の検定)
|
311
334
|
#
|
312
335
|
# @overload pearsoCorrelation(x, y, a)
|
313
336
|
# @param [Array] x xのデータ(double[])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: num4tststatistic2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: num4tststatistic
|