num4tststatistic 0.0.1-java → 0.0.3-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: a8b0c9145ecc7379e5619ad7f8ffb33b61d5560bf92c594e42f53e5c0e288a1b
4
- data.tar.gz: e8b836c2974645183f78e3e9c6533b105b3d364f2405c10c68ab18372f06e685
3
+ metadata.gz: 8c015fe7102176f7c7c2314cc1dfb6622c07bc8fe1e5b36c3417c0c1df3e255a
4
+ data.tar.gz: f348504d4e1245853d4cc93a19e4dbe16fa1c4ac9ef6be75f53d8f4b7d1df767
5
5
  SHA512:
6
- metadata.gz: 20fa87418cb04465c0c62d33dd64016e67a57ad9f0c0dccddf2572b8f6aa6618ddbc76ff6111c12baa414103e24cc8dc74abcec87dfac38768e28a3ae80233f5
7
- data.tar.gz: a01a432d8a7530b3be8f568e047faed5a42d9d79dde68f60426bcda8a751c166212e772495bd74e7b4277d3e7045e9443a5993c19a5af36b451306486dce528f
6
+ metadata.gz: a93a631e82744d7d8130e32951caf07a82d6b0530d74f2fb54fda082dfb8269f8ccdcad69a99e3a9b81e14399077b10ec42b8b6f6b2e535704da87bf993c4a5b
7
+ data.tar.gz: 19cc9ecf0e5bcc36ec32bfed81ffa8b3301588617267edac4e1be18c5e4ddae8f8f8d693a7b67503c9c8c79c227c7104f324ef56a45486ee6d1fc7f812084a57
data/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [0.0.3] - 2023-11-16
6
+
7
+ ### add
8
+ - add function of grubbs.
9
+
10
+ ## [0.0.2] - 2023-11-15
11
+
12
+ ### add
13
+ - add function of fidelity and independency.
14
+
5
15
  ## [0.0.1] - 2023-11-11
6
16
 
7
17
  ### Fixed
@@ -130,6 +130,62 @@ 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
+ }
175
+ public static double grubbs(double[] xi, double xk) {
176
+ SummaryStatistics stat = new SummaryStatistics();
177
+
178
+ Arrays.stream(xi).forEach(stat::addValue);
179
+ double m = stat.getMean(); // 平均
180
+ double sd = stat.getStandardDeviation();// 標準偏差
181
+ double min = stat.getMin();
182
+ double max = stat.getMax();
183
+ double t = 0.0;
184
+
185
+ if (xk == min) { t = (m - xk) / sd; }
186
+ if (xk == max) { t = (xk - m) / sd; }
187
+ return t;
188
+ }
133
189
  }
134
190
 
135
191
 
@@ -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,54 @@ 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
231
+ # グラプス・スミルノフの外れ値の検定量
232
+ #
233
+ # @overload grubbs(xi, xk)
234
+ # @param [Array] xi xiのデータ(double[])
235
+ # @param [double] xk 外れ値
236
+ # @return [double] 検定統計量
237
+ # @example
238
+ # xi = [3.4, 3.5, 3.3, 2.2, 3.3, 3.4, 3.6, 3.2]
239
+ # Num4TstStatisticLib.grubbs(xi, 2.2)
240
+ # => 2.3724
241
+ # @note
242
+ # グラプス・スミルノフの数表に従う
243
+ def grubbs(xi, xk)
244
+ return TstStatistic.grubbs(xi.to_java(Java::double), xk)
245
+ end
198
246
  end
199
247
  end
200
248
 
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.3
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-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake