num4anova 0.0.13-java → 0.0.14-java

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 84f7f49327e10a3da88a363daa4d6d5dec1dd4da00827d6f8e5c60ee6db4bc08
4
- data.tar.gz: 495495a96d218034014971770b654431bb0df61aec47f8f3171fe351285022c4
3
+ metadata.gz: 844b392125f78a4966a67dd1162bef6676857f03ed9f49e48d4f00e9f294d6e9
4
+ data.tar.gz: da4999753cf5b2b73336b365c53e79ad5eb084fcb44151fdf6c05b5c691a40d2
5
5
  SHA512:
6
- metadata.gz: 1b46cc7670940eb88343959c80bad55209a981388acdd823c3d9eeafa72a629d2319cfb49707f3f998d72f0d080480785129c948c8ebedb388693476be59add1
7
- data.tar.gz: 83585b2c13c1f964b8bf92e507a005deb4d358a612e23b939cb9d9911175006a1378e16719c1b73073834aa510f245b4432f0aba9f5dfcdceb78ee2cf5638ba3
6
+ metadata.gz: 6c8e9884146305d0db99633f36997de0dc3ec4593e2b497fa6f97c1d9cf957721ad233914454e2eb1f8334b86871fdb389f073d62492904432da76415f9a302f
7
+ data.tar.gz: 79b9cc886c7f2f8b794c204db714ca5663e9b9acb0388eee8afd60cef393b9f107e3f32f05855f848c53e39fc67f42212d352d87c0fdc2262718178f6d36d1d1
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.0.14] - 2024-04-08
6
+
7
+ ### add
8
+ - add fuction of bonferrono_test in NonParametrixTestLib.
9
+
5
10
  ## [0.0.13] - 2024-04-04
6
11
 
7
12
  ### chg
@@ -3,9 +3,17 @@ import java.util.Arrays;
3
3
  import java.util.List;
4
4
  import java.util.ArrayList;
5
5
  import org.apache.commons.math3.distribution.TDistribution;
6
+ import org.apache.commons.math3.stat.inference.MannWhitneyUTest;
6
7
 
7
8
  import org.apache.commons.math3.util.Combinations;
8
9
  public class MultiComp {
10
+ /*********************************/
11
+ /* interface define */
12
+ /*********************************/
13
+ private interface HypothesisTest {
14
+ double[][] calcTestStatistic(double[][] xi);
15
+ boolean[][] executeTest(double[][] statistic, double a);
16
+ }
9
17
  public static class ParametrixTest {
10
18
  private static ParametrixTest paramTest = new ParametrixTest();
11
19
  public static ParametrixTest getInstance() {
@@ -46,13 +54,6 @@ public class MultiComp {
46
54
  return hypoth.executeTest(statistic, a);
47
55
  }
48
56
  /*********************************/
49
- /* interface define */
50
- /*********************************/
51
- private interface HypothesisTest {
52
- double[][] calcTestStatistic(double[][] xi);
53
- boolean[][] executeTest(double[][] statistic, double a);
54
- }
55
- /*********************************/
56
57
  /* Class define */
57
58
  /*********************************/
58
59
  // turkey法
@@ -366,5 +367,55 @@ public class MultiComp {
366
367
  }
367
368
  }
368
369
  }
370
+ public static class NonParametrixTest {
371
+ private static NonParametrixTest nonParamTest = new NonParametrixTest();
372
+ public static NonParametrixTest getInstance() {
373
+ return nonParamTest;
374
+ }
375
+ public boolean[][] bonferronoTest(double[][] xi, double a) {
376
+ HypothesisTest hypoth = new BonferroniTest();
377
+
378
+ double[][] statistic = hypoth.calcTestStatistic(xi);
379
+ return hypoth.executeTest(statistic, a * 0.5);
380
+ }
381
+ /*********************************/
382
+ /* Class define */
383
+ /*********************************/
384
+ // ボンフェロー法
385
+ private class BonferroniTest implements HypothesisTest {
386
+ private int n = 0;
387
+ private int k = 0;
388
+ public double[][] calcTestStatistic(double[][] xi) {
389
+ n = xi.length;
390
+ double[][] statistic = new double[n][n];
391
+ //
392
+ Combinations c = new Combinations(n, 2);
393
+ List<int[]> al = new ArrayList<>();
394
+ for(int[] iterate : c) {
395
+ al.add(iterate);
396
+ }
397
+ k = al.size();
398
+ //
399
+ MannWhitneyUTest utest = new MannWhitneyUTest();
400
+ for(int[] array : al) {
401
+ int i = array[0];
402
+ int j = array[1];
403
+
404
+ statistic[i][j] = utest.mannWhitneyUTest(xi[i], xi[j]);
405
+ }
406
+ return statistic;
407
+ }
408
+ public boolean[][] executeTest(double[][] statistic, double a) {
409
+ boolean[][] ret = new boolean[n][n];
410
+
411
+ for(int i = 0; i < n; i++) {
412
+ for(int j = i+1; j < n; j++) {
413
+ ret[i][j] = (statistic[i][j] < a * k) ? true : false;
414
+ }
415
+ }
416
+ return ret;
417
+ }
418
+ }
419
+ }
369
420
  }
370
421
 
data/lib/multicomp.rb CHANGED
@@ -43,7 +43,7 @@ module MultiCompLib
43
43
  ret = @paramTest.turkeyTest(xi.to_java(Java::double[]), a)
44
44
  return ret.to_a
45
45
  end
46
- # ボンフェロー二の不等式による多重比較
46
+ # ボンフェロー二の不等式による多重比較(T検定)
47
47
  #
48
48
  # @overload bonferrono_test(xi, a)
49
49
  # @param [array] xi データ(double[][])
@@ -74,5 +74,37 @@ module MultiCompLib
74
74
  end
75
75
  # ノンパラメトリック検定
76
76
  class NonParametrixTestLib
77
+ def initialize
78
+ @nonParamTest = MultiComp::NonParametrixTest.getInstance()
79
+ end
80
+ # ボンフェロー二の不等式による多重比較(マン・ホイットニーU検定)
81
+ #
82
+ # @overload bonferrono_test(xi, a)
83
+ # @param [array] xi データ(double[][])
84
+ # @param [double] a 有意水準
85
+ # @return [Array] 検定結果(boolean[][] true:棄却域内 false:棄却域外)
86
+ # @example
87
+ # xi = [
88
+ # [12.2, 18.8, 18.2],
89
+ # [22.2, 20.5, 14.6],
90
+ # [20.8, 19.5, 26.3],
91
+ # [26.4, 32.5, 31.3],
92
+ # [24.5, 21.2, 22.4],
93
+ # ]
94
+ # nonParaTest = MultiCompLib::NonParametrixTestLib.new
95
+ # nonParaTest.bonferrono_test(xi, 0.05)
96
+ # =>
97
+ # [
98
+ # [false, false, true, true, true],
99
+ # [false, false, false, true, true],
100
+ # [false, false, false, true, false],
101
+ # [false, false, false, false, true],
102
+ # [false, false, false, false, false],
103
+ # ]
104
+ def bonferrono_test(xi, a)
105
+ ret = @nonParamTest.bonferronoTest(xi.to_java(Java::double[]), a)
106
+ return ret.to_a
107
+ end
108
+
77
109
  end
78
110
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: num4anova
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.13
4
+ version: 0.0.14
5
5
  platform: java
6
6
  authors:
7
7
  - siranovel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-04 00:00:00.000000000 Z
11
+ date: 2024-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake