num4normality 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 +8 -0
- data/ext/num4normality/Normality.java +31 -14
- data/lib/num4normality.rb +12 -0
- 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: 58c526a9c71f5640706a0e7b57c5491b46bc93b7194ed7ef1c6031d49986d0a4
|
4
|
+
data.tar.gz: 51966044b28deae90af5f764bac62692243312cfcbd6a6013d4a54b8389d009f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7c158d1d3f06e7390757264b06b70ce6081f8d57e4b6d84627a10ba834b1ae8422d38e18216e7faee81f9fc15d649b701af3f42131be504225e31c1131fdc55
|
7
|
+
data.tar.gz: f109895d5434021a9073180c4717b1db3fa081f9ed89d116d8883ff03318d9be3739f40227f8dc713f8fc576984497bd84889099f9aefec689ee12a60d01978e
|
data/CHANGELOG.md
CHANGED
@@ -21,6 +21,7 @@ import java.io.IOException;
|
|
21
21
|
|
22
22
|
import org.apache.commons.math3.stat.descriptive.DescriptiveStatistics;
|
23
23
|
import org.apache.commons.math3.distribution.NormalDistribution;
|
24
|
+
import org.apache.commons.math3.distribution.ChiSquaredDistribution;
|
24
25
|
import org.apache.commons.math3.stat.regression.SimpleRegression;
|
25
26
|
import java.util.Arrays;
|
26
27
|
import java.text.DecimalFormat;
|
@@ -57,6 +58,12 @@ public class Normality {
|
|
57
58
|
double b2 = daigo.calcTestStatistic(xi);
|
58
59
|
return daigo.test(b2, 0.05);
|
59
60
|
}
|
61
|
+
public static boolean omnibustest(double[] xi) {
|
62
|
+
DAgostinosTest daigo = new OmnibusTest();
|
63
|
+
|
64
|
+
double x = daigo.calcTestStatistic(xi);
|
65
|
+
return daigo.test(x, 0.05);
|
66
|
+
}
|
60
67
|
|
61
68
|
|
62
69
|
private interface ChartPlot {
|
@@ -298,14 +305,14 @@ public class Normality {
|
|
298
305
|
public boolean test(double statistic, double a) {
|
299
306
|
double ua_2 = ndist.inverseCumulativeProbability(1.0 - a / 2.0);
|
300
307
|
|
301
|
-
return (Math.abs(statistic) >
|
308
|
+
return (Math.abs(statistic) > calcNormStatic(ua_2))
|
302
309
|
? true : false;
|
303
310
|
}
|
304
|
-
private double
|
311
|
+
private double calcNormStatic(double ua_2) {
|
305
312
|
double el = (n + 1.0) * (n + 1.0) * (n + 3.0) * (n + 5.0); // 分子
|
306
313
|
double den = 24 * n * (n - 2.0) * (n - 3.0); // 分母
|
307
314
|
double b2p = Math.sqrt(el / den) *
|
308
|
-
(
|
315
|
+
(ua_2 + 3.0 / (2.0 * n) * (ua_2 * ua_2 * ua_2 - 3 * ua_2));
|
309
316
|
|
310
317
|
return b2p;
|
311
318
|
}
|
@@ -322,33 +329,43 @@ public class Normality {
|
|
322
329
|
|
323
330
|
Arrays.stream(xi).forEach(stat::addValue);
|
324
331
|
n = stat.getN();
|
325
|
-
|
326
332
|
return stat.getKurtosis();
|
327
333
|
}
|
328
334
|
public boolean test(double statistic, double a) {
|
329
335
|
boolean ret = false;
|
330
336
|
double ua_2 = ndist.inverseCumulativeProbability(1.0 - a / 2.0);
|
331
|
-
double b2p = cnvb2tob2p(statistic);
|
332
337
|
|
333
338
|
double r_val = ua_2 + Math.sqrt(6.0 / n) * (ua_2 * ua_2 - 1.0);
|
334
339
|
double l_val = -1.0 * ua_2 + Math.sqrt(6.0 / n) * (ua_2 * ua_2 - 1.0);
|
335
340
|
|
336
|
-
if (
|
341
|
+
if (statistic > r_val) {
|
337
342
|
ret = true;
|
338
343
|
}
|
339
|
-
if (
|
344
|
+
if (statistic < l_val) {
|
340
345
|
ret = true;
|
341
346
|
}
|
342
347
|
return ret;
|
343
348
|
}
|
344
|
-
|
345
|
-
|
346
|
-
|
349
|
+
}
|
350
|
+
// オムニバス検定
|
351
|
+
private static class OmnibusTest implements DAgostinosTest {
|
352
|
+
private DAgostinosTest skewness = null;
|
353
|
+
private DAgostinosTest kurtosis = null;
|
354
|
+
public OmnibusTest() {
|
355
|
+
skewness = new SkewnessTest();
|
356
|
+
kurtosis = new KurtosisTest();
|
357
|
+
}
|
358
|
+
public double calcTestStatistic(double[] xi) {
|
359
|
+
double x1 = skewness.calcTestStatistic(xi);
|
360
|
+
double x2 = kurtosis.calcTestStatistic(xi);
|
347
361
|
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
362
|
+
return x1 * x1 + x2 * x2;
|
363
|
+
}
|
364
|
+
public boolean test(double statistic, double a) {
|
365
|
+
ChiSquaredDistribution chi2Dist = new ChiSquaredDistribution(2);
|
366
|
+
double p = chi2Dist.cumulativeProbability(statistic);
|
367
|
+
|
368
|
+
return (p < a) ? true : false;
|
352
369
|
}
|
353
370
|
}
|
354
371
|
}
|
data/lib/num4normality.rb
CHANGED
@@ -76,6 +76,18 @@ module Num4NormalityLib
|
|
76
76
|
def kurtosistest(xi)
|
77
77
|
Normality.kurtosistest(xi.to_java(Java::double))
|
78
78
|
end
|
79
|
+
# オムニバス検定
|
80
|
+
#
|
81
|
+
# @overload omnibustest(xi)
|
82
|
+
# @param [Array] xi データ(double[])
|
83
|
+
# @return [boolean] 検定結果(true:棄却域内 false:棄却域外)
|
84
|
+
# @example
|
85
|
+
# xi = [320, 240, 402, 325, 440, 286, 362, 281, 560, 212, 198, 209, 374]
|
86
|
+
# Num4NormalityLib.omnibustest(xi)
|
87
|
+
# => false
|
88
|
+
def omnibustest(xi)
|
89
|
+
Normality.omnibustest(xi.to_java(Java::double))
|
90
|
+
end
|
79
91
|
end
|
80
92
|
end
|
81
93
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: num4normality
|
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-12-
|
11
|
+
date: 2023-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|