num4normality 0.0.3-java → 0.0.4-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a735c6ff8848bf8f8c56b7e1bc0b1794a5675ab93d3e9a13477cf8d3041b50d9
4
- data.tar.gz: 87b102e787cd5835ce2c78ebf11e0abf8a2092462cbf9ff7fd73e06a3884d43b
3
+ metadata.gz: 58c526a9c71f5640706a0e7b57c5491b46bc93b7194ed7ef1c6031d49986d0a4
4
+ data.tar.gz: 51966044b28deae90af5f764bac62692243312cfcbd6a6013d4a54b8389d009f
5
5
  SHA512:
6
- metadata.gz: c808547090cef242d28bbfbc46243fc44726a69d22c18a03916f76ccb7e91b58b7c3a074f1fe7fd7a17c492da9978197358db941c20c1255fcd90773cc28e54d
7
- data.tar.gz: ff78669f413ae51fae98f4fb683981b12793f2a93eaeb17438124e1ad3771b476a34955e4482bc669bcd4044ec31a95f08e9c0c93b89a802b03fe7d664d03c4c
6
+ metadata.gz: f7c158d1d3f06e7390757264b06b70ce6081f8d57e4b6d84627a10ba834b1ae8422d38e18216e7faee81f9fc15d649b701af3f42131be504225e31c1131fdc55
7
+ data.tar.gz: f109895d5434021a9073180c4717b1db3fa081f9ed89d116d8883ff03318d9be3739f40227f8dc713f8fc576984497bd84889099f9aefec689ee12a60d01978e
data/CHANGELOG.md CHANGED
@@ -2,6 +2,14 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.0.4] - 2023-12-21
6
+
7
+ ### add
8
+ - add function of omnibustest.
9
+
10
+ ### Fixed
11
+ - fix fuction of kurtosistest.
12
+
5
13
  ## [0.0.3] - 2023-12-18
6
14
 
7
15
  ### add
@@ -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) > cnvb2tob2p(ua_2))
308
+ return (Math.abs(statistic) > calcNormStatic(ua_2))
302
309
  ? true : false;
303
310
  }
304
- private double cnvb2tob2p(double ua_2) {
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
- (long)(ua_2 + 3.0 / (2.0 * n) * (ua_2 * ua_2 * ua_2 - 3 * ua_2));
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 (b2p > r_val) {
341
+ if (statistic > r_val) {
337
342
  ret = true;
338
343
  }
339
- if (b2p < l_val) {
344
+ if (statistic < l_val) {
340
345
  ret = true;
341
346
  }
342
347
  return ret;
343
348
  }
344
- private double cnvb2tob2p(double b2) {
345
- double el = (n + 1.0) * (n + 1.0) * (n + 3.0) * (n + 5.0); // 分子
346
- double den = 24 * n * (n - 2.0) * (n - 3.0); // 分母
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
- double b2p = Math.sqrt(el / den) *
349
- (long)(b2 - 3 * (n - 1.0) / (n + 3.0));
350
-
351
- return b2p;
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.3
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-18 00:00:00.000000000 Z
11
+ date: 2023-12-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake