Skip to content

Commit e1fec49

Browse files
authored
Remove unreachable code and unused variables (#823)
1 parent 0528c1c commit e1fec49

9 files changed

+5
-62
lines changed

lib/model/markov_switching.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ export default class MarkovSwitching {
153153
}
154154
}
155155
}
156-
const [ms, ss, ps, ls] = this._mcmc(x, eps, trial)
156+
this._mcmc(x, eps, trial)
157157
}
158158

159159
/**

lib/model/monte_carlo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class MCTable extends QTableBase {
1313
let last_g = 0
1414
for (let i = actions.length - 1; i >= 0; i--) {
1515
const [action, cur_state, reward] = actions[i]
16-
const [_, gs] = this._q(this._state_index(cur_state), this._action_index(action))
16+
const [, gs] = this._q(this._state_index(cur_state), this._action_index(action))
1717
last_g = reward + this._gamma * last_g
1818
this._g[gs] = (last_g + this._g[gs] * this._epoch) / (this._epoch + 1)
1919
this._table[gs] = this._g[gs]

lib/model/nice.js

-3
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ export default class NICE {
2424

2525
this._model = NeuralNetwork.fromObject(layers, null, optimizer)
2626
this._epoch = 0
27-
this._p = z => {
28-
return Matrix.map(z, v => Math.exp(-(v ** 2) / 2) / Math.sqrt(2 * Math.PI))
29-
}
3027
}
3128

3229
/**

lib/model/optics.js

-5
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ export default class OPTICS {
9595
neighbors.sort((a, b) => a - b)
9696
return neighbors[this._minPts]
9797
}
98-
const reachabilityDist = (o, i) => {
99-
const cd = coreDist(i)
100-
if (cd === null) return cd
101-
return Math.max(cd, d[i][o])
102-
}
10398

10499
const processed = Array(n).fill(false)
105100
const rd = Array(n).fill(null)

lib/model/orclus.js

-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export default class ORCLUS {
1717
this._l = l
1818
this._alpha = 0.5
1919
this._beta = null
20-
21-
this._d = (a, b) => Math.sqrt(a.reduce((s, v, i) => s + (v - b[i]) ** 2, 0))
2220
}
2321

2422
_pdist(a, b, e) {

lib/model/smirnov_grubbs.js

+1-46
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,7 @@ const ibeta = (x, a, b) => {
4646
const e = 1.0e-12
4747
for (let n = 1; n < 1000; n++) {
4848
if (Math.abs(g2 - g0) < e) break
49-
const n2 = n * 2,
50-
n2a = n * 2 * a
49+
const n2a = n * 2 * a
5150
c0 = (x * n * (b - n)) / (n2a * (n2a - 1))
5251
c1 = (-x * (a + n) * (a + b + n)) / (n2a * (n2a + 1))
5352

@@ -115,50 +114,6 @@ const qt = (n, a) => {
115114
throw 'qt not converged.'
116115
}
117116

118-
// https://bellcurve.jp/statistics/course/8970.html
119-
// http://www.geisya.or.jp/~mwm48961/statistics/sample3.htm
120-
// https://ai-trend.jp/basic-study/t-distribution/t-table/
121-
const tTable = [
122-
[3.078, 6.314, 12.706, 31.821, 63.657],
123-
[1.886, 2.92, 4.303, 6.965, 9.925],
124-
[1.638, 2.353, 3.182, 4.541, 5.841],
125-
[1.533, 2.132, 2.776, 3.747, 4.604],
126-
[1.476, 2.015, 2.571, 3.365, 4.032],
127-
[1.44, 1.943, 2.447, 3.143, 3.707],
128-
[1.415, 1.895, 2.365, 2.998, 3.499],
129-
[1.397, 1.86, 2.306, 2.896, 3.355],
130-
[1.383, 1.833, 2.262, 2.821, 3.25],
131-
[1.372, 1.812, 2.228, 2.764, 3.169],
132-
[1.363, 1.796, 2.201, 2.718, 3.106],
133-
[1.356, 1.782, 2.179, 2.681, 3.055],
134-
[1.35, 1.771, 2.16, 2.65, 3.012],
135-
[1.345, 1.761, 2.145, 2.624, 2.977],
136-
[1.341, 1.753, 2.131, 2.602, 2.947],
137-
[1.337, 1.746, 2.12, 2.583, 2.921],
138-
[1.333, 1.74, 2.11, 2.567, 2.898],
139-
[1.33, 1.734, 2.101, 2.552, 2.878],
140-
[1.328, 1.729, 2.093, 2.539, 2.861],
141-
[1.325, 1.725, 2.086, 2.528, 2.845],
142-
[1.323, 1.721, 2.08, 2.518, 2.831],
143-
[1.321, 1.717, 2.074, 2.508, 2.819],
144-
[1.319, 1.714, 2.069, 2.5, 2.807],
145-
[1.318, 1.711, 2.064, 2.492, 2.797],
146-
[1.316, 1.708, 2.06, 2.485, 2.787],
147-
[1.315, 1.706, 2.056, 2.479, 2.779],
148-
[1.314, 1.703, 2.052, 2.473, 2.771],
149-
[1.313, 1.701, 2.048, 2.467, 2.763],
150-
[1.311, 1.699, 2.045, 2.462, 2.756],
151-
[1.31, 1.697, 2.042, 2.457, 2.75],
152-
]
153-
const v40 = [1.303, 1.684, 2.021, 2.423, 2.704]
154-
const v60 = [1.296, 1.671, 2.0, 2.39, 2.66]
155-
const v80 = [1.292, 1.664, 1.99, 2.374, 2.639]
156-
const v120 = [1.289, 1.658, 1.98, 2.358, 2.617]
157-
const v180 = [1.286, 1.653, 1.973, 2.347, 2.603]
158-
const v240 = [1.285, 1.651, 1.97, 2.342, 2.596]
159-
const vinf = [1.258, 1.645, 1.96, 2.326, 2.576]
160-
const p = [0.1, 0.05, 0.025, 0.01, 0.005]
161-
162117
/**
163118
* SmirnovGrubbs test
164119
*/

lib/model/yinyang_kmeans.js

-2
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ export default class YinyangKMeans {
155155
}
156156
}
157157

158-
const lb_old = []
159-
const b_old = []
160158
for (let i = 0; i < n; i++) {
161159
this._ub[i] += delta_c[this._b[i]]
162160
const lb_old = []

lib/rl/gomoku.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ class GomokuBoard {
257257
}
258258
}
259259

260-
choices(turn) {
260+
choices() {
261261
const c = []
262262
if (this.finish) {
263263
return c

lib/util/tensor.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Matrix, { MatrixException } from './matrix.js'
22

3-
const normal_random = function (m = 0, s = 1) {
3+
const normal_random = function (m, s) {
44
const std = Math.sqrt(s)
55
const x = Math.random()
66
const y = Math.random()

0 commit comments

Comments
 (0)