num4tststatistic 0.0.1-java → 0.0.2-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: a8b0c9145ecc7379e5619ad7f8ffb33b61d5560bf92c594e42f53e5c0e288a1b
4
- data.tar.gz: e8b836c2974645183f78e3e9c6533b105b3d364f2405c10c68ab18372f06e685
3
+ metadata.gz: 7cf4040a8f70a0ee55f1bcbb70397220d88aaab31d3edaf96dc2b8d4e9589bea
4
+ data.tar.gz: b1eb211d1b876bbd7a801b4a9eb8398eca8ba1d3dd1b4eee72783d73b0b691b2
5
5
  SHA512:
6
- metadata.gz: 20fa87418cb04465c0c62d33dd64016e67a57ad9f0c0dccddf2572b8f6aa6618ddbc76ff6111c12baa414103e24cc8dc74abcec87dfac38768e28a3ae80233f5
7
- data.tar.gz: a01a432d8a7530b3be8f568e047faed5a42d9d79dde68f60426bcda8a751c166212e772495bd74e7b4277d3e7045e9443a5993c19a5af36b451306486dce528f
6
+ metadata.gz: b2802b5d55555c08234609c5d1cf29a5e6ce223aab56cf2b3a66b34ee3cd1078fd94ecc4ef05a069709d56c03ac51abcad2e05aa9a8fe0c88fa34e57a1428c5b
7
+ data.tar.gz: fa23a4ebe88f4dd924651a6976956948bf3ad9494dbdd7ea77a26123b5d45bc86dd40e7b88bffe4c31e231cfe2a02ebd6726f78b140277d061a517361c8f54b5
data/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.0.2] - 2023-11-15
6
+
7
+ ### add
8
+ - add function of fidelity and independency.
9
+
5
10
  ## [0.0.1] - 2023-11-11
6
11
 
7
12
  ### Fixed
@@ -130,6 +130,48 @@ public class TstStatistic {
130
130
  - 0.5 * Math.log((1.0 + rth0) / (1.0 - rth0))
131
131
  );
132
132
  }
133
+ public static double fidelity(double[] fi, double[] pi) {
134
+ double[] e = new double[fi.length];
135
+ double t = 0.0;
136
+ SummaryStatistics stat = new SummaryStatistics();
137
+
138
+ Arrays.stream(fi).forEach(stat::addValue);
139
+ double s = stat.getSum();
140
+
141
+ for (int i = 0; i < fi.length; i++) {
142
+ e[i] = s * pi[i];
143
+ double f_e = fi[i] - e[i];
144
+ t += f_e * f_e / e[i];
145
+ }
146
+ return t;
147
+ }
148
+ public static double independency(double[][] fij) {
149
+ double t = 0.0;
150
+ long n = 0;
151
+ double[] fa = new double[fij.length];
152
+ double[] fb = new double[fij[0].length];
153
+
154
+ // 各セルの計算
155
+ for (int i = 0; i < fij.length; i++) {
156
+ fa[i] = 0.0;
157
+ for (int j = 0; j < fij[i].length; j++) {
158
+ fa[i] += fij[i][j];
159
+ fb[j] += fij[i][j];
160
+ n += fij[i][j];
161
+ }
162
+ }
163
+
164
+ // 検定統計量計算
165
+ for (int i = 0; i < fij.length; i++) {
166
+ for (int j = 0; j < fij[i].length; j++) {
167
+ double f_e = n * fij[i][j] - fa[i] * fb[j];
168
+
169
+ t += f_e * f_e / (n * fa[i] * fb[j]);
170
+ }
171
+ }
172
+
173
+ return t;
174
+ }
133
175
  }
134
176
 
135
177
 
@@ -58,7 +58,7 @@ module Num4TstStatisticLib
58
58
  #
59
59
  # @overload diffPopulationMean2EquVar(xi1, xi2)
60
60
  # @param [Array] xi1 x1のデータ(double[])
61
- # @param [Array] xi2 x2のデータ)double[])
61
+ # @param [Array] xi2 x2のデータ(double[])
62
62
  # @return [double] 検定統計量
63
63
  # @example
64
64
  # xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
@@ -77,7 +77,7 @@ module Num4TstStatisticLib
77
77
  #
78
78
  # @overload diffPopulationMean2UnEquVar(xi1, xi2)
79
79
  # @param [Array] xi1 x1のデータ(double[])
80
- # @param [Array] xi2 x2のデータ)double[])
80
+ # @param [Array] xi2 x2のデータ(double[])
81
81
  # @return [double] 検定統計量
82
82
  # @example
83
83
  # xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
@@ -94,7 +94,7 @@ module Num4TstStatisticLib
94
94
  # ウェルチ検定の為の自由度
95
95
  # @overload df4welch(xi1, xi2)
96
96
  # @param [Array] xi1 x1のデータ(double[])
97
- # @param [Array] xi2 x2のデータ)double[])
97
+ # @param [Array] xi2 x2のデータ(double[])
98
98
  # @return [int] 自由度
99
99
  # @example
100
100
  # xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
@@ -110,7 +110,7 @@ module Num4TstStatisticLib
110
110
  #
111
111
  # @overload diffPopulationMean(xi1, xi2)
112
112
  # @param [Array] xi1 x1のデータ(double[])
113
- # @param [Array] xi2 x2のデータ)double[])
113
+ # @param [Array] xi2 x2のデータ(double[])
114
114
  # @return [double] 検定統計量
115
115
  # @example
116
116
  # xi1 = [37.1, 36.2, 36.6, 37.4, 36.8, 36.7, 36.9, 37.4, 36.6, 36.7]
@@ -126,9 +126,9 @@ module Num4TstStatisticLib
126
126
  end
127
127
  # 2つの母分散の差の検定量
128
128
  #
129
- # @oerload diffPopulationVar(xi1, xi2)
129
+ # @overload diffPopulationVar(xi1, xi2)
130
130
  # @param [Array] xi1 x1のデータ(double[])
131
- # @param [Array] xi2 x2のデータ)double[])
131
+ # @param [Array] xi2 x2のデータ(double[])
132
132
  # @return [double] 検定統計量
133
133
  # @example
134
134
  # xi1 = [165, 130, 182, 178, 194, 206, 160, 122, 212, 165, 247, 195]
@@ -162,7 +162,7 @@ module Num4TstStatisticLib
162
162
  #
163
163
  # @overload unCorrelation(x, y)
164
164
  # @param [Array] x xのデータ(double[])
165
- # @param [Array] y yのデータ)double[])
165
+ # @param [Array] y yのデータ(double[])
166
166
  # @return [double] 検定統計量
167
167
  # @example
168
168
  # x = [113, 64, 16, 45, 28, 19, 30, 82, 76]
@@ -180,7 +180,7 @@ module Num4TstStatisticLib
180
180
  #
181
181
  # @overload populationCorre(x, y, rth0)
182
182
  # @param [Array] x xのデータ(double[])
183
- # @param [Array] y yのデータ)double[])
183
+ # @param [Array] y yのデータ(double[])
184
184
  # @param [double] rth0 母相関係数
185
185
  # @return [double] 検定統計量
186
186
  # @example
@@ -195,6 +195,39 @@ module Num4TstStatisticLib
195
195
  x.to_java(Java::double), y.to_java(Java::double), rth0
196
196
  )
197
197
  end
198
+ # 適合度の検定量
199
+ #
200
+ # @overload fidelity(fi, pi)
201
+ # @param [Array] fi 実測度数(double[])
202
+ # @param [Array] pi 比率(double[])
203
+ # @return [double] 検定統計量
204
+ # @example
205
+ # fi = [57, 33, 46, 14]
206
+ # pi = [0.4, 0.2, 0.3, 0.1]
207
+ # Num4TstStatisticLib.fidelity(fi, pi)
208
+ # => 0.5389
209
+ # @note
210
+ # 自由度(n-1)の階2乗分布に従う
211
+ def fidelity(fi, pi)
212
+ return TstStatistic.fidelity(fi.to_java(Java::double), pi.to_java(Java::double))
213
+ end
214
+ # 独立性の検定量
215
+ #
216
+ # @overload independency(fij)
217
+ # @param [Array] fij 実測度数(double[])
218
+ # @return [double] 検定統計量
219
+ # @example
220
+ # fij = [
221
+ # [57, 33, 46, 14],
222
+ # [89, 24, 75, 12],
223
+ # ]
224
+ # Num4TstStatisticLib.independency(fij)
225
+ # => 8.5711
226
+ # @note
227
+ # 自由度(m-1)(n-1)の階2乗分布に従う
228
+ def independency(fij)
229
+ return TstStatistic.independency(fij.to_java(Java::double[]))
230
+ end
198
231
  end
199
232
  end
200
233
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: num4tststatistic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: java
6
6
  authors:
7
7
  - siranovel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-11 00:00:00.000000000 Z
11
+ date: 2023-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake