num4tststatistic2 0.0.1 → 0.1.1
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 +13 -1
- data/Gemfile +3 -2
- data/lib/decorrtest.rb +22 -0
- data/lib/num4tststatistic2.rb +146 -27
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60785711542acd092cb1688f03e95bb31b372dab71e52048ec6adec7fcc2bcf5
|
4
|
+
data.tar.gz: fc3dd84abfa51c591061cde8e4ebad3e56985dbb0ae30928f8456a2488aa9c42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bccb6876cf7adb09a192dd34faf6fbd4f29652974e1cced0ae49bde5e30ce19c9c9a171db5744e2cd4128a3bbaf2a9d56c43720825693348c056bfe84b81e68b
|
7
|
+
data.tar.gz: 1f8c945bc94f924990b7451d809ed883c0e7dee6ab4b25ab1c08c822314d7a4c9e1a4ba5d8f0c749369efd319e579aedc83d3cd7c1abaa37dc54ea2acf69c9b3
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,19 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
-
## [0.
|
5
|
+
## [0.1.1] - 2024-05-06
|
6
|
+
|
7
|
+
### add
|
8
|
+
- add function of diffPopulationMean2.
|
9
|
+
- add CorreFact.
|
10
|
+
|
11
|
+
## [0.0.2] - 2024-04-22
|
12
|
+
|
13
|
+
### add
|
14
|
+
- add version in Gemfile.
|
15
|
+
- add raise function.
|
16
|
+
|
17
|
+
## [0.0.1] - 2024-04-20
|
6
18
|
|
7
19
|
### Fixed
|
8
20
|
- fix first fixed.
|
data/Gemfile
CHANGED
data/lib/decorrtest.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
class DecorrTestIF
|
2
|
+
def pearsoCorrelation(x, y, a)
|
3
|
+
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません")
|
4
|
+
end
|
5
|
+
def spearmanscorr(x, y, a)
|
6
|
+
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません")
|
7
|
+
end
|
8
|
+
def kendallscorr(x, y, a)
|
9
|
+
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
class CorreFactIF
|
13
|
+
def pearsoCorrelation(x, y, rth0, a)
|
14
|
+
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません")
|
15
|
+
end
|
16
|
+
def spearmanscorr(x, y, rth0, a)
|
17
|
+
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません")
|
18
|
+
end
|
19
|
+
def kendallscorr(x, y, rth0, a)
|
20
|
+
raise NotImplementedError.new("#{self.class}##{__method__} が実装されていません")
|
21
|
+
end
|
22
|
+
end
|
data/lib/num4tststatistic2.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
require 'num4tststatistic'
|
2
2
|
require 'hypothTest3'
|
3
|
+
require_relative('decorrtest')
|
3
4
|
|
4
5
|
# 統計的仮説検定
|
5
6
|
module Num4TstStatistic2Lib
|
7
|
+
# パラメトリック検定
|
6
8
|
class ParametrixTestLib
|
7
9
|
def initialize(hypothTest3)
|
8
10
|
@hypothTest3 = hypothTest3
|
@@ -16,12 +18,14 @@ module Num4TstStatistic2Lib
|
|
16
18
|
# @param [double] a 有意水準
|
17
19
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
18
20
|
# @example
|
19
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
20
21
|
# xi = [15.5, 15.7, 15.4, 15.4, 15.6, 15.4, 15.6, 15.5, 15.4]
|
21
|
-
#
|
22
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
23
|
+
# paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
|
22
24
|
# paraTest.populationMean(xi, 15.4, 0.05)
|
23
25
|
# => true
|
24
26
|
def populationMean(xi, m0, a)
|
27
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
28
|
+
|
25
29
|
df = xi.size - 1
|
26
30
|
statistic = @paraTest.populationMean(xi, m0)
|
27
31
|
return @hypothTest3.tDistTest(statistic, df, a)
|
@@ -41,11 +45,13 @@ module Num4TstStatistic2Lib
|
|
41
45
|
# paraTest.populationVar(xi, sd*sd, 0.05)
|
42
46
|
# => true
|
43
47
|
def populationVar(xi, sig0, a)
|
48
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
49
|
+
|
44
50
|
df = xi.size - 1
|
45
51
|
statistic = @paraTest.populationVar(xi, sig0)
|
46
52
|
return @hypothTest3.chi2DistTest(statistic, df, a)
|
47
53
|
end
|
48
|
-
#
|
54
|
+
# 母比率の検定
|
49
55
|
#
|
50
56
|
# @overload populationRatio(m, n, p0, a)
|
51
57
|
# @param [int] m m値
|
@@ -59,11 +65,34 @@ module Num4TstStatistic2Lib
|
|
59
65
|
# paraTest.populationRatio(29, 346, 0.12, 0.05)
|
60
66
|
# => true
|
61
67
|
def populationRatio(m, n, p0, a)
|
68
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
69
|
+
|
62
70
|
statistic = @paraTest.populationRatio(m, n, p0)
|
63
71
|
return @hypothTest3.normDistTest(statistic, a)
|
64
72
|
end
|
65
|
-
# 2
|
66
|
-
#
|
73
|
+
# 2つの母平均の差の検定
|
74
|
+
#
|
75
|
+
# @overload diffPopulationMean2(xi1, xi2, a)
|
76
|
+
# @param [Array] xi1 x1のデータ(double[])
|
77
|
+
# @param [Array] xi2 x2のデータ(double[])
|
78
|
+
# @param [double] a 有意水準
|
79
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
80
|
+
# @example
|
81
|
+
# xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
|
82
|
+
# xi2 = [180, 180, 235, 270, 240, 285, 164, 152]
|
83
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
84
|
+
# paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
|
85
|
+
# paraTest.diffPopulationMean2(xi1, xi2, 0.05)
|
86
|
+
# => false
|
87
|
+
def diffPopulationMean2(xi1, xi2, a)
|
88
|
+
bRet = diffPopulationVar(xi1, xi2, a)
|
89
|
+
if bRet == true # 等分散ではない
|
90
|
+
return diffPopulationMean2UnEquVar(xi1, xi2, a)
|
91
|
+
else # 等分散性
|
92
|
+
return diffPopulationMean2EquVar(xi1, xi2, a)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
# 2つの母平均の差の検定(等分散性を仮定)
|
67
96
|
#
|
68
97
|
# @overload diffPopulationMean2EquVar(xi1, xi2, a)
|
69
98
|
# @param [Array] xi1 x1のデータ(double[])
|
@@ -78,14 +107,15 @@ module Num4TstStatistic2Lib
|
|
78
107
|
# paraTest.diffPopulationMean2EquVar(xi1, xi2, 0.05)
|
79
108
|
# => false
|
80
109
|
def diffPopulationMean2EquVar(xi1, xi2, a)
|
110
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
111
|
+
|
81
112
|
n1 = xi1.size
|
82
113
|
n2 = xi2.size
|
83
114
|
df = n1 + n2 - 2
|
84
115
|
statistic = @paraTest.diffPopulationMean2EquVar(xi1, xi2)
|
85
116
|
return @hypothTest3.tDistTest(statistic, df, a)
|
86
117
|
end
|
87
|
-
# 2
|
88
|
-
# (不等分散性を仮定)
|
118
|
+
# 2つの母平均の差の検定(不等分散性を仮定)
|
89
119
|
#
|
90
120
|
# @overload diffPopulationMean2UnEquVar(xi1, xi2, a)
|
91
121
|
# @param [Array] xi1 x1のデータ(double[])
|
@@ -100,6 +130,8 @@ module Num4TstStatistic2Lib
|
|
100
130
|
# paraTest.diffPopulationMean2UnEquVar(xi1, xi2, 0.05)
|
101
131
|
# => false
|
102
132
|
def diffPopulationMean2UnEquVar(xi1, xi2, a)
|
133
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
134
|
+
|
103
135
|
df = @paraTest.df4welch(xi1, xi2)
|
104
136
|
statistic = @paraTest.diffPopulationMean2UnEquVar(xi1, xi2)
|
105
137
|
return @hypothTest3.tDistTest(statistic, df, a)
|
@@ -119,12 +151,14 @@ module Num4TstStatistic2Lib
|
|
119
151
|
# paraTest.diffPopulationMean(xi1, xi2, 0.05)
|
120
152
|
# => true
|
121
153
|
def diffPopulationMean(xi1, xi2, a)
|
154
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
155
|
+
|
122
156
|
n = xi1.size
|
123
157
|
df = n - 1
|
124
158
|
statistic = @paraTest.diffPopulationMean(xi1, xi2)
|
125
159
|
return @hypothTest3.tDistTest(statistic, df, a)
|
126
160
|
end
|
127
|
-
# 2
|
161
|
+
# 2つの母分散の差の検定
|
128
162
|
#
|
129
163
|
# @overload diffPopulationVar(xi1, xi2, a)
|
130
164
|
# @param [Array] xi1 x1のデータ(double[])
|
@@ -139,12 +173,14 @@ module Num4TstStatistic2Lib
|
|
139
173
|
# paraTest.diffPopulationVar(xi1, xi2, 0.05)
|
140
174
|
# => false
|
141
175
|
def diffPopulationVar(xi1, xi2, a)
|
176
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
177
|
+
|
142
178
|
nf = xi1.size - 1
|
143
179
|
df = xi2.size - 1
|
144
180
|
statistic = @paraTest.diffPopulationVar(xi1, xi2)
|
145
181
|
return @hypothTest3.fDistTest(statistic, nf, df, a)
|
146
182
|
end
|
147
|
-
# 2
|
183
|
+
# 2つの母比率の差の検定
|
148
184
|
#
|
149
185
|
# @overload diffPopulationRatio(m1, n1, m2, n2, a)
|
150
186
|
# @param [int] m1 m1値
|
@@ -159,10 +195,12 @@ module Num4TstStatistic2Lib
|
|
159
195
|
# paraTest.diffPopulationRatio(469, 1200, 308, 900, 0.05)
|
160
196
|
# => true
|
161
197
|
def diffPopulationRatio(m1, n1, m2, n2, a)
|
198
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
199
|
+
|
162
200
|
statistic = @paraTest.diffPopulationRatio(m1, n1, m2, n2)
|
163
201
|
return @hypothTest3.normDistTest(statistic, a)
|
164
202
|
end
|
165
|
-
#
|
203
|
+
# 適合度の検定
|
166
204
|
#
|
167
205
|
# @overload fidelity(fi, pi, a)
|
168
206
|
# @param [Array] fi 実測度数(double[])
|
@@ -177,11 +215,13 @@ module Num4TstStatistic2Lib
|
|
177
215
|
# paraTest.fidelity(fi, pi, 0.05)
|
178
216
|
# => false
|
179
217
|
def fidelity(fi, pi, a)
|
218
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
219
|
+
|
180
220
|
df = fi.size - 1
|
181
221
|
statistic = @paraTest.fidelity(fi, pi)
|
182
222
|
return @hypothTest3.chi2DistTest(statistic, df, a)
|
183
223
|
end
|
184
|
-
#
|
224
|
+
# 独立性の検定
|
185
225
|
#
|
186
226
|
# @overload independency(fij, a)
|
187
227
|
# @param [Array] fij 実測度数(double[][])
|
@@ -197,6 +237,8 @@ module Num4TstStatistic2Lib
|
|
197
237
|
# paraTest.independency(fij, 0.05)
|
198
238
|
# => true
|
199
239
|
def independency(fij, a)
|
240
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
241
|
+
|
200
242
|
m = fij.size
|
201
243
|
n = fij[0].size
|
202
244
|
df = (m - 1) * (n - 1)
|
@@ -204,6 +246,7 @@ module Num4TstStatistic2Lib
|
|
204
246
|
return @hypothTest3.chi2DistTest(statistic, df, a)
|
205
247
|
end
|
206
248
|
end
|
249
|
+
# ノンパラメトリック検定
|
207
250
|
class NonParametrixTestLib
|
208
251
|
def initialize(hypothTest3)
|
209
252
|
@hypothTest3 = hypothTest3
|
@@ -217,13 +260,15 @@ module Num4TstStatistic2Lib
|
|
217
260
|
# @param [double] a 有意水準
|
218
261
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
219
262
|
# @example
|
220
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
221
263
|
# x = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
|
222
264
|
# y = [180, 180, 235, 270, 240, 285, 164, 152]
|
265
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
223
266
|
# nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
|
224
267
|
# nonParaTest.utest(x, y, 0.05)
|
225
268
|
# => true
|
226
269
|
def utest(x, y, a)
|
270
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
271
|
+
|
227
272
|
statistic = @nonParaTest.utest(x, y)
|
228
273
|
return @hypothTest3.normDistTest(statistic, a)
|
229
274
|
end
|
@@ -235,13 +280,15 @@ module Num4TstStatistic2Lib
|
|
235
280
|
# @param [double] a 有意水準
|
236
281
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
237
282
|
# @example
|
238
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
239
283
|
# x = [37.1, 36.2, 36.6, 37.4, 36.8, 36.7, 36.9, 37.4, 36.6, 36.7]
|
240
284
|
# y = [36.8, 36.6, 36.5, 37.0, 36.0, 36.5, 36.6, 37.1, 36.4, 36.7]
|
285
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
241
286
|
# nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
|
242
287
|
# nonParaTest.wilcoxon(x, y, 0.05)
|
243
288
|
# => true
|
244
289
|
def wilcoxon(x, y, a)
|
290
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
291
|
+
|
245
292
|
statistic = @nonParaTest.wilcoxon(x, y)
|
246
293
|
return @hypothTest3.normDistTest(statistic, a)
|
247
294
|
end
|
@@ -253,22 +300,25 @@ module Num4TstStatistic2Lib
|
|
253
300
|
# @param [double] a 有意水準
|
254
301
|
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
255
302
|
# @example
|
256
|
-
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
257
303
|
# xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
|
258
304
|
# xi2 = [180, 180, 235, 270, 240, 285, 164, 152]
|
259
|
-
#
|
305
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
306
|
+
# nonParaTest = Num4TstStatistic2Lib::NonParametrixTestLib.new(hypothTest)
|
260
307
|
# nonParaTest.ks2test(xi1, xi2, 0.05)
|
261
308
|
# => false
|
262
309
|
def ks2test(xi1, xi2, a)
|
310
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
311
|
+
|
263
312
|
return @nonParaTest.ks2test(xi1, xi2, a)
|
264
313
|
end
|
265
314
|
end
|
315
|
+
# 外れ値検定
|
266
316
|
class OutlierLib
|
267
317
|
def initialize
|
268
318
|
@outlier = Num4TstStatisticLib::OutlierLib.new
|
269
319
|
@hypothTest2 = Num4HypothTestLib::GrubbsTestLib.new
|
270
320
|
end
|
271
|
-
#
|
321
|
+
# グラプス・スミルノフの外れ値の検定
|
272
322
|
#
|
273
323
|
# @overload grubbs(xi, xk, a)
|
274
324
|
# @param [Array] xi xiのデータ(double[])
|
@@ -276,7 +326,7 @@ module Num4TstStatistic2Lib
|
|
276
326
|
# @return [double] 検定統計量
|
277
327
|
# @example
|
278
328
|
# xi = [3.4, 3.5, 3.3, 2.2, 3.3, 3.4, 3.6, 3.2]
|
279
|
-
# outlier =
|
329
|
+
# outlier = Num4TstStatistic2Lib::OutlierLib.new
|
280
330
|
# outlier.grubbs(xi, 2.2, 0.05)
|
281
331
|
# => true
|
282
332
|
def grubbs(xi, xk, a)
|
@@ -292,22 +342,24 @@ module Num4TstStatistic2Lib
|
|
292
342
|
# @return [void] errbar.jpegファイルを出力
|
293
343
|
# @example
|
294
344
|
# xi = [3.4, 3.5, 3.3, 2.2, 3.3, 3.4, 3.6, 3.2]
|
295
|
-
# outlier =
|
345
|
+
# outlier = Num4TstStatistic2Lib::OutlierLib.new
|
296
346
|
# outlier.grubbs("LDH", xi)
|
297
347
|
# => errbar.jpeg
|
298
348
|
def errbar(dname, xi)
|
299
349
|
@outlier.errbar(dname, xi)
|
300
350
|
end
|
301
351
|
end
|
352
|
+
end
|
353
|
+
# 相関検定
|
354
|
+
module DecorrTestLib
|
302
355
|
# 無相関の検定
|
303
|
-
class
|
356
|
+
class UnDecorrTestLib < DecorrTestIF
|
304
357
|
def initialize
|
305
358
|
@paraTest = Num4TstStatisticLib::ParametrixTestLib.new
|
306
359
|
@nonParaTest = Num4TstStatisticLib::NonParametrixTestLib.new
|
307
360
|
@hypothTest = Num4HypothTestLib::DecorrTestLib.new
|
308
361
|
end
|
309
362
|
# ピアソン相関係数
|
310
|
-
# (相関係数の検定)
|
311
363
|
#
|
312
364
|
# @overload pearsoCorrelation(x, y, a)
|
313
365
|
# @param [Array] x xのデータ(double[])
|
@@ -317,8 +369,8 @@ module Num4TstStatistic2Lib
|
|
317
369
|
# @example
|
318
370
|
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
319
371
|
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
320
|
-
#
|
321
|
-
#
|
372
|
+
# decorrTest = DecorrTestLib::UnDecorrTestLib.new
|
373
|
+
# decorrTest.pearsoCorrelation(x, y, 0.05)
|
322
374
|
# => true
|
323
375
|
def pearsoCorrelation(x, y, a)
|
324
376
|
df = x.size - 2
|
@@ -335,8 +387,8 @@ module Num4TstStatistic2Lib
|
|
335
387
|
# @example
|
336
388
|
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
337
389
|
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
338
|
-
#
|
339
|
-
#
|
390
|
+
# decorrTest = DecorrTestLib::UnDecorrTestLib.new
|
391
|
+
# decorrTest.spearmanscorr(x, y, 0.05)
|
340
392
|
# => true
|
341
393
|
def spearmanscorr(x, y, a)
|
342
394
|
df = x.size - 2
|
@@ -353,8 +405,8 @@ module Num4TstStatistic2Lib
|
|
353
405
|
# @example
|
354
406
|
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
355
407
|
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
356
|
-
#
|
357
|
-
#
|
408
|
+
# decorrTest = DecorrTestLib::UnDecorrTestLib.new
|
409
|
+
# decorrTest.kendallscorr(x, y, 0.05)
|
358
410
|
# => false
|
359
411
|
def kendallscorr(x, y, a)
|
360
412
|
df = x.size - 2
|
@@ -362,5 +414,72 @@ module Num4TstStatistic2Lib
|
|
362
414
|
return @hypothTest.twoSideTest(statistic, df, a)
|
363
415
|
end
|
364
416
|
end
|
417
|
+
# 相関係数の検定
|
418
|
+
class CorreFactLib < CorreFactIF
|
419
|
+
def initialize(hypothTest3)
|
420
|
+
@hypothTest3 = hypothTest3
|
421
|
+
@paraTest = Num4TstStatisticLib::ParametrixTestLib.new
|
422
|
+
@nonParaTest = Num4TstStatisticLib::NonParametrixTestLib.new
|
423
|
+
end
|
424
|
+
# ピアソン相関係数
|
425
|
+
#
|
426
|
+
# @overload pearsoCorrelation(x, y, rth0, a)
|
427
|
+
# @param [Array] x xのデータ(double[])
|
428
|
+
# @param [Array] y yのデータ(double[])
|
429
|
+
# @param [double] rth0 母相関係数
|
430
|
+
# @param [double] a 有意水準
|
431
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
432
|
+
# @example
|
433
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
434
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
435
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
436
|
+
# decorrTest = DecorrTestLib::CorreFactLib.new(hypothTest)
|
437
|
+
# decorrTest.pearsoCorrelation(x, y, -0.3, 0.05)
|
438
|
+
# => true
|
439
|
+
def pearsoCorrelation(x, y, rth0, a)
|
440
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
441
|
+
statistic = @paraTest.pearsoCorrelation(x, y)
|
442
|
+
return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
|
443
|
+
end
|
444
|
+
# スピアマンの順位相関係数
|
445
|
+
#
|
446
|
+
# @overload spearmanscorr(x, y, rth0, a)
|
447
|
+
# @param [Array] x xのデータ(double[])
|
448
|
+
# @param [Array] y yのデータ(double[])
|
449
|
+
# @param [double] rth0 母相関係数
|
450
|
+
# @param [double] a 有意水準
|
451
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
452
|
+
# @example
|
453
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
454
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
455
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
456
|
+
# decorrTest = DecorrTestLib::CorreFactLib.new(hypothTest)
|
457
|
+
# decorrTest.spearmanscorr(x, y, -0.3, 0.05)
|
458
|
+
# => true
|
459
|
+
def spearmanscorr(x, y, rth0, a)
|
460
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
461
|
+
statistic = @nonParaTest.spearmanscorr(x, y)
|
462
|
+
return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
|
463
|
+
end
|
464
|
+
# ケンドールの順位相関係数
|
465
|
+
#
|
466
|
+
# @overload kendallscorr(x, y, rth0, a)
|
467
|
+
# @param [Array] x xのデータ(double[])
|
468
|
+
# @param [Array] y yのデータ(double[])
|
469
|
+
# @param [double] rth0 母相関係数
|
470
|
+
# @param [double] a 有意水準
|
471
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
472
|
+
# @example
|
473
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
474
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
475
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
476
|
+
# decorrTest = DecorrTestLib::CorreFactLib.new(hypothTest)
|
477
|
+
# decorrTest.kendallscorr(x, y, -0.3, 0.05)
|
478
|
+
# => true
|
479
|
+
def kendallscorr(x, y, rth0, a)
|
480
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
481
|
+
statistic = @nonParaTest.kendallscorr(x, y)
|
482
|
+
return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
|
483
|
+
end
|
484
|
+
end
|
365
485
|
end
|
366
|
-
|
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.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- siranovel
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: num4tststatistic
|
@@ -59,8 +59,9 @@ files:
|
|
59
59
|
- CHANGELOG.md
|
60
60
|
- Gemfile
|
61
61
|
- LICENSE
|
62
|
+
- lib/decorrtest.rb
|
62
63
|
- lib/num4tststatistic2.rb
|
63
|
-
homepage:
|
64
|
+
homepage: https://github.com/siranovel/num4tststatistic2
|
64
65
|
licenses:
|
65
66
|
- MIT
|
66
67
|
metadata: {}
|