num4tststatistic2 0.0.2 → 0.1.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 +11 -0
- data/lib/corrtest.rb +151 -0
- data/lib/num4tststatistic2.rb +27 -63
- 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: cfd90c54dab3784be95fad71d373a338e24c17a41b0bb5ddde46e46d77a4e739
|
4
|
+
data.tar.gz: 6fa678137d1a9b7fa3336a8f61bdc3fe03d89cb67c6ece3ff5ddb27c5216cfb3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20ec74c474a5d8524ab8c18eac95b33ac5c0bc96241a8aa8dea2aa3a2bb41d633c90aad4561611f25f421b68af754b5ebae32ac08a1ceb73b0ae672a1c9714ef
|
7
|
+
data.tar.gz: 2520663599be76415a0fb3a6106d096f5697be92fdbf1371affff34ac4f9aa1b6da0f24e36c5ef7150e6cd2eec05d94207fd38be17a97552ab78326d3e583e6a
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
|
3
3
|
## Unreleased
|
4
4
|
|
5
|
+
## [0.1.2] - 2024-05-08
|
6
|
+
|
7
|
+
### chg
|
8
|
+
- change function name from diffPopulationMean2 to diffPopulationVarMean
|
9
|
+
|
10
|
+
## [0.1.1] - 2024-05-06
|
11
|
+
|
12
|
+
### add
|
13
|
+
- add function of diffPopulationMean2.
|
14
|
+
- add CorreFact.
|
15
|
+
|
5
16
|
## [0.0.2] - 2024-04-22
|
6
17
|
|
7
18
|
### add
|
data/lib/corrtest.rb
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
require 'num4tststatistic'
|
2
|
+
require 'hypothTest3'
|
3
|
+
|
4
|
+
# 相関検定
|
5
|
+
module CorrTestLib
|
6
|
+
# 無相関の検定
|
7
|
+
class DecorrTestLib
|
8
|
+
def initialize
|
9
|
+
@corr = CorrStatisticLib.new
|
10
|
+
@hypothTest = Num4HypothTestLib::DecorrTestLib.new
|
11
|
+
end
|
12
|
+
# ピアソン相関係数
|
13
|
+
#
|
14
|
+
# @overload pearsoCorrelation(x, y, a)
|
15
|
+
# @param [Array] x xのデータ(double[])
|
16
|
+
# @param [Array] y yのデータ(double[])
|
17
|
+
# @param [double] a 有意水準
|
18
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
19
|
+
# @example
|
20
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
21
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
22
|
+
# corrTest = CorrTestLib::DecorrTestLib.new
|
23
|
+
# corrTest.pearsoCorrelation(x, y, 0.05)
|
24
|
+
# => true
|
25
|
+
def pearsoCorrelation(x, y, a)
|
26
|
+
df = x.size - 2
|
27
|
+
statistic = @corr.pearsoCorrelation(x, y)
|
28
|
+
return @hypothTest.twoSideTest(statistic, df, a)
|
29
|
+
end
|
30
|
+
# スピアマンの順位相関係数
|
31
|
+
#
|
32
|
+
# @overload spearmanscorr(x, y, a)
|
33
|
+
# @param [Array] x xのデータ(double[])
|
34
|
+
# @param [Array] y yのデータ(double[])
|
35
|
+
# @param [double] a 有意水準
|
36
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
37
|
+
# @example
|
38
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
39
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
40
|
+
# corrTest = CorrTestLib::DecorrTestLib.new
|
41
|
+
# corrTest.spearmanscorr(x, y, 0.05)
|
42
|
+
# => true
|
43
|
+
def spearmanscorr(x, y, a)
|
44
|
+
df = x.size - 2
|
45
|
+
statistic = @corr.spearmanscorr(x, y)
|
46
|
+
return @hypothTest.twoSideTest(statistic, df, a)
|
47
|
+
end
|
48
|
+
# ケンドールの順位相関係数
|
49
|
+
#
|
50
|
+
# @overload kendallscorr(x, y, a)
|
51
|
+
# @param [Array] x xのデータ(double[])
|
52
|
+
# @param [Array] y yのデータ(double[])
|
53
|
+
# @param [double] a 有意水準
|
54
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
55
|
+
# @example
|
56
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
57
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
58
|
+
# corrTest = CorrTestLib::DecorrTestLib.new
|
59
|
+
# corrTest.kendallscorr(x, y, 0.05)
|
60
|
+
# => false
|
61
|
+
def kendallscorr(x, y, a)
|
62
|
+
df = x.size - 2
|
63
|
+
statistic = @corr.kendallscorr(x, y)
|
64
|
+
return @hypothTest.twoSideTest(statistic, df, a)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
# 母相関係数の検定
|
68
|
+
class CorreFactLib
|
69
|
+
def initialize(hypothTest3)
|
70
|
+
@hypothTest3 = hypothTest3
|
71
|
+
@corr = CorrStatisticLib.new
|
72
|
+
end
|
73
|
+
# ピアソン相関係数
|
74
|
+
#
|
75
|
+
# @overload pearsoCorrelation(x, y, rth0, a)
|
76
|
+
# @param [Array] x xのデータ(double[])
|
77
|
+
# @param [Array] y yのデータ(double[])
|
78
|
+
# @param [double] rth0 母相関係数
|
79
|
+
# @param [double] a 有意水準
|
80
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
81
|
+
# @example
|
82
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
83
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
84
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
85
|
+
# corrTest = CorrTestLib::CorreFactLib.new(hypothTest)
|
86
|
+
# corrTest.pearsoCorrelation(x, y, -0.3, 0.05)
|
87
|
+
# => true
|
88
|
+
def pearsoCorrelation(x, y, rth0, a)
|
89
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
90
|
+
statistic = @corr.pearsoCorrelation(x, y)
|
91
|
+
return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
|
92
|
+
end
|
93
|
+
# スピアマンの順位相関係数
|
94
|
+
#
|
95
|
+
# @overload spearmanscorr(x, y, rth0, a)
|
96
|
+
# @param [Array] x xのデータ(double[])
|
97
|
+
# @param [Array] y yのデータ(double[])
|
98
|
+
# @param [double] rth0 母相関係数
|
99
|
+
# @param [double] a 有意水準
|
100
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
101
|
+
# @example
|
102
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
103
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
104
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
105
|
+
# corrTest = CorrTestLib::CorreFactLib.new(hypothTest)
|
106
|
+
# corrTest.spearmanscorr(x, y, -0.3, 0.05)
|
107
|
+
# => true
|
108
|
+
def spearmanscorr(x, y, rth0, a)
|
109
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
110
|
+
statistic = @corr.spearmanscorr(x, y)
|
111
|
+
return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
|
112
|
+
end
|
113
|
+
# ケンドールの順位相関係数
|
114
|
+
#
|
115
|
+
# @overload kendallscorr(x, y, rth0, a)
|
116
|
+
# @param [Array] x xのデータ(double[])
|
117
|
+
# @param [Array] y yのデータ(double[])
|
118
|
+
# @param [double] rth0 母相関係数
|
119
|
+
# @param [double] a 有意水準
|
120
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
121
|
+
# @example
|
122
|
+
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
123
|
+
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
124
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
125
|
+
# corrTest = CorrTestLib::CorreFactLib.new(hypothTest)
|
126
|
+
# corrTest.kendallscorr(x, y, -0.3, 0.05)
|
127
|
+
# => true
|
128
|
+
def kendallscorr(x, y, rth0, a)
|
129
|
+
raise TypeError unless @hypothTest3.kind_of?(HypothTest3IF)
|
130
|
+
statistic = @corr.kendallscorr(x, y)
|
131
|
+
return @hypothTest3.populationCorre(statistic, x.size, rth0, a)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
class CorrStatisticLib
|
136
|
+
def initialize
|
137
|
+
@paraTest = Num4TstStatisticLib::ParametrixTestLib.new
|
138
|
+
@nonParaTest = Num4TstStatisticLib::NonParametrixTestLib.new
|
139
|
+
end
|
140
|
+
def pearsoCorrelation(x, y)
|
141
|
+
return @paraTest.pearsoCorrelation(x, y)
|
142
|
+
end
|
143
|
+
def spearmanscorr(x, y)
|
144
|
+
return @nonParaTest.spearmanscorr(x, y)
|
145
|
+
end
|
146
|
+
def kendallscorr(x, y)
|
147
|
+
return @nonParaTest.kendallscorr(x, y)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
private_constant :CorrStatisticLib
|
151
|
+
end
|
data/lib/num4tststatistic2.rb
CHANGED
@@ -3,6 +3,7 @@ require 'hypothTest3'
|
|
3
3
|
|
4
4
|
# 統計的仮説検定
|
5
5
|
module Num4TstStatistic2Lib
|
6
|
+
# パラメトリック検定
|
6
7
|
class ParametrixTestLib
|
7
8
|
def initialize(hypothTest3)
|
8
9
|
@hypothTest3 = hypothTest3
|
@@ -68,6 +69,29 @@ module Num4TstStatistic2Lib
|
|
68
69
|
statistic = @paraTest.populationRatio(m, n, p0)
|
69
70
|
return @hypothTest3.normDistTest(statistic, a)
|
70
71
|
end
|
72
|
+
# 2つの母平均の差の検定
|
73
|
+
#
|
74
|
+
# @overload diffPopulationVarMean(xi1, xi2, a)
|
75
|
+
# @param [Array] xi1 x1のデータ(double[])
|
76
|
+
# @param [Array] xi2 x2のデータ(double[])
|
77
|
+
# @param [double] a 有意水準
|
78
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
79
|
+
# @example
|
80
|
+
# xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
|
81
|
+
# xi2 = [180, 180, 235, 270, 240, 285, 164, 152]
|
82
|
+
# hypothTest = Num4HypothTestLib::TwoSideTestLib.new
|
83
|
+
# paraTest = Num4TstStatistic2Lib::ParametrixTestLib.new(hypothTest)
|
84
|
+
# paraTest.diffPopulationVarMean(xi1, xi2, 0.05)
|
85
|
+
# => false
|
86
|
+
def diffPopulationVarMean(xi1, xi2, a)
|
87
|
+
bRet = diffPopulationVar(xi1, xi2, a)
|
88
|
+
|
89
|
+
if bRet == true # 等分散ではない
|
90
|
+
return diffPopulationMean2UnEquVar(xi1, xi2, a)
|
91
|
+
else # 等分散性
|
92
|
+
return diffPopulationMean2EquVar(xi1, xi2, a)
|
93
|
+
end
|
94
|
+
end
|
71
95
|
# 2つの母平均の差の検定(等分散性を仮定)
|
72
96
|
#
|
73
97
|
# @overload diffPopulationMean2EquVar(xi1, xi2, a)
|
@@ -222,6 +246,7 @@ module Num4TstStatistic2Lib
|
|
222
246
|
return @hypothTest3.chi2DistTest(statistic, df, a)
|
223
247
|
end
|
224
248
|
end
|
249
|
+
# ノンパラメトリック検定
|
225
250
|
class NonParametrixTestLib
|
226
251
|
def initialize(hypothTest3)
|
227
252
|
@hypothTest3 = hypothTest3
|
@@ -287,6 +312,7 @@ module Num4TstStatistic2Lib
|
|
287
312
|
return @nonParaTest.ks2test(xi1, xi2, a)
|
288
313
|
end
|
289
314
|
end
|
315
|
+
# 外れ値検定
|
290
316
|
class OutlierLib
|
291
317
|
def initialize
|
292
318
|
@outlier = Num4TstStatisticLib::OutlierLib.new
|
@@ -317,73 +343,11 @@ module Num4TstStatistic2Lib
|
|
317
343
|
# @example
|
318
344
|
# xi = [3.4, 3.5, 3.3, 2.2, 3.3, 3.4, 3.6, 3.2]
|
319
345
|
# outlier = Num4TstStatistic2Lib::OutlierLib.new
|
320
|
-
# outlier.
|
346
|
+
# outlier.errbar("LDH", xi)
|
321
347
|
# => errbar.jpeg
|
322
348
|
def errbar(dname, xi)
|
323
349
|
@outlier.errbar(dname, xi)
|
324
350
|
end
|
325
351
|
end
|
326
|
-
# 無相関の検定
|
327
|
-
class DecorrTestLib
|
328
|
-
def initialize
|
329
|
-
@paraTest = Num4TstStatisticLib::ParametrixTestLib.new
|
330
|
-
@nonParaTest = Num4TstStatisticLib::NonParametrixTestLib.new
|
331
|
-
@hypothTest = Num4HypothTestLib::DecorrTestLib.new
|
332
|
-
end
|
333
|
-
# ピアソン相関係数
|
334
|
-
#
|
335
|
-
# @overload pearsoCorrelation(x, y, a)
|
336
|
-
# @param [Array] x xのデータ(double[])
|
337
|
-
# @param [Array] y yのデータ(double[])
|
338
|
-
# @param [double] a 有意水準
|
339
|
-
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
340
|
-
# @example
|
341
|
-
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
342
|
-
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
343
|
-
# paraTest = Num4TstStatistic2Lib::DecorrTestLib.new
|
344
|
-
# paraTest.pearsoCorrelation(x, y, 0.05)
|
345
|
-
# => true
|
346
|
-
def pearsoCorrelation(x, y, a)
|
347
|
-
df = x.size - 2
|
348
|
-
statistic = @paraTest.pearsoCorrelation(x, y)
|
349
|
-
return @hypothTest.twoSideTest(statistic, df, a)
|
350
|
-
end
|
351
|
-
# スピアマンの順位相関係数
|
352
|
-
#
|
353
|
-
# @overload spearmanscorr(x, y, a)
|
354
|
-
# @param [Array] x xのデータ(double[])
|
355
|
-
# @param [Array] y yのデータ(double[])
|
356
|
-
# @param [double] a 有意水準
|
357
|
-
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
358
|
-
# @example
|
359
|
-
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
360
|
-
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
361
|
-
# paraTest = Num4TstStatistic2Lib::DecorrTestLib.new
|
362
|
-
# paraTest.spearmanscorr(x, y, 0.05)
|
363
|
-
# => true
|
364
|
-
def spearmanscorr(x, y, a)
|
365
|
-
df = x.size - 2
|
366
|
-
statistic = @nonParaTest.spearmanscorr(x, y)
|
367
|
-
return @hypothTest.twoSideTest(statistic, df, a)
|
368
|
-
end
|
369
|
-
# ケンドールの順位相関係数
|
370
|
-
#
|
371
|
-
# @overload kendallscorr(x, y, a)
|
372
|
-
# @param [Array] x xのデータ(double[])
|
373
|
-
# @param [Array] y yのデータ(double[])
|
374
|
-
# @param [double] a 有意水準
|
375
|
-
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
376
|
-
# @example
|
377
|
-
# x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
|
378
|
-
# y = [31, 5, 2, 17, 18, 2, 9, 25, 13]
|
379
|
-
# paraTest = Num4TstStatistic2Lib::DecorrTestLib.new
|
380
|
-
# paraTest.kendallscorr(x, y, 0.05)
|
381
|
-
# => false
|
382
|
-
def kendallscorr(x, y, a)
|
383
|
-
df = x.size - 2
|
384
|
-
statistic = @nonParaTest.kendallscorr(x, y)
|
385
|
-
return @hypothTest.twoSideTest(statistic, df, a)
|
386
|
-
end
|
387
|
-
end
|
388
352
|
end
|
389
353
|
|
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.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-
|
11
|
+
date: 2024-05-08 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/corrtest.rb
|
62
63
|
- lib/num4tststatistic2.rb
|
63
|
-
homepage:
|
64
|
+
homepage: https://github.com/siranovel/num4tststatistic2
|
64
65
|
licenses:
|
65
66
|
- MIT
|
66
67
|
metadata: {}
|