Comparing version 1.8.1 to 1.8.2
{ | ||
"name": "jstat", | ||
"version": "1.8.1", | ||
"version": "1.8.2", | ||
"description": "Statistical Library for JavaScript", | ||
@@ -5,0 +5,0 @@ "homepage": "http://github.com/jstat/jstat", |
@@ -51,4 +51,2 @@ var jStat = (function(Math, undefined) { | ||
jStat._init = function _init(args) { | ||
var i; | ||
// If first argument is an array, must be vector or matrix. | ||
@@ -107,2 +105,10 @@ if (isArray(args[0])) { | ||
jStat._random_fn = Math.random; | ||
jStat.setRandom = function setRandom(fn) { | ||
if (typeof fn !== 'function') | ||
throw new TypeError('fn is not a function'); | ||
jStat._random_fn = fn; | ||
}; | ||
// Easily extend the jStat object. | ||
@@ -119,3 +125,3 @@ // TODO: is this seriously necessary? | ||
for (var i = 1; i < arguments.length; i++) { | ||
for (i = 1; i < arguments.length; i++) { | ||
for (j in arguments[i]) | ||
@@ -172,3 +178,3 @@ obj[j] = arguments[i][j]; | ||
if (isArray(index)) { | ||
var submat = jStat.arange(arr.length).map(function(i) { | ||
var submat = jStat.arange(arr.length).map(function() { | ||
return new Array(index.length); | ||
@@ -228,3 +234,3 @@ }); | ||
for (var i = 0; i < cols; i++) { | ||
for (i = 0; i < cols; i++) { | ||
objArr = new Array(rows); | ||
@@ -305,3 +311,3 @@ for (j = 0; j < rows; j++) | ||
for (var i = 0; i < rows; i++) { | ||
for (i = 0; i < rows; i++) { | ||
res[i] = new Array(cols); | ||
@@ -342,3 +348,3 @@ for (j = 0; j < cols; j++) | ||
cols = rows; | ||
return jStat.create(rows, cols, Math.random); | ||
return jStat.create(rows, cols, jStat._random_fn); | ||
}; | ||
@@ -360,3 +366,2 @@ | ||
jStat.symmetric = function symmetric(arr) { | ||
var issymmetric = true; | ||
var size = arr.length; | ||
@@ -481,2 +486,3 @@ var row, col; | ||
function slice(list, rcSlice) { | ||
var colSlice, rowSlice; | ||
rcSlice = rcSlice || {}; | ||
@@ -487,3 +493,3 @@ if (isNumber(rcSlice.row)) { | ||
var row = jStat.rowa(list, rcSlice.row); | ||
var colSlice = rcSlice.col || {}; | ||
colSlice = rcSlice.col || {}; | ||
return _slice(row, colSlice.start, colSlice.end, colSlice.step); | ||
@@ -494,8 +500,8 @@ } | ||
var col = jStat.cola(list, rcSlice.col); | ||
var rowSlice = rcSlice.row || {}; | ||
rowSlice = rcSlice.row || {}; | ||
return _slice(col, rowSlice.start, rowSlice.end, rowSlice.step); | ||
} | ||
var rowSlice = rcSlice.row || {}; | ||
var colSlice = rcSlice.col || {}; | ||
rowSlice = rcSlice.row || {}; | ||
colSlice = rcSlice.col || {}; | ||
var rows = _slice(list, rowSlice.start, rowSlice.end, rowSlice.step); | ||
@@ -515,2 +521,3 @@ return rows.map(function(row) { | ||
jStat.sliceAssign = function sliceAssign(A, rcSlice, B) { | ||
var nl, ml; | ||
if (isNumber(rcSlice.row)) { | ||
@@ -523,3 +530,3 @@ if (isNumber(rcSlice.col)) | ||
rcSlice.col.step = rcSlice.col.step || 1; | ||
var nl = jStat.arange(rcSlice.col.start, | ||
nl = jStat.arange(rcSlice.col.start, | ||
Math.min(A.length, rcSlice.col.end), | ||
@@ -539,3 +546,3 @@ rcSlice.col.step); | ||
rcSlice.row.step = rcSlice.row.step || 1; | ||
var ml = jStat.arange(rcSlice.row.start, | ||
ml = jStat.arange(rcSlice.row.start, | ||
Math.min(A[0].length, rcSlice.row.end), | ||
@@ -559,6 +566,6 @@ rcSlice.row.step); | ||
rcSlice.col.step = rcSlice.col.step || 1; | ||
var ml = jStat.arange(rcSlice.row.start, | ||
ml = jStat.arange(rcSlice.row.start, | ||
Math.min(A.length, rcSlice.row.end), | ||
rcSlice.row.step); | ||
var nl = jStat.arange(rcSlice.col.start, | ||
nl = jStat.arange(rcSlice.col.start, | ||
Math.min(A[0].length, rcSlice.col.end), | ||
@@ -565,0 +572,0 @@ rcSlice.col.step); |
@@ -199,7 +199,7 @@ (function(jStat, Math) { | ||
median: function median(local, scale) { | ||
median: function median(local/*, scale*/) { | ||
return local; | ||
}, | ||
mode: function mode(local, scale) { | ||
mode: function mode(local/*, scale*/) { | ||
return local; | ||
@@ -282,3 +282,3 @@ }, | ||
mode: function mode(rate) { | ||
mode: function mode(/*rate*/) { | ||
return 0; | ||
@@ -288,3 +288,3 @@ }, | ||
sample: function sample(rate) { | ||
return -1 / rate * Math.log(Math.random()); | ||
return -1 / rate * Math.log(jStat._random_fn()); | ||
}, | ||
@@ -415,3 +415,3 @@ | ||
variance: function variance(alpha, beta) { | ||
variance: function variance(/*alpha, beta*/) { | ||
throw new Error('variance not yet implemented'); | ||
@@ -449,3 +449,3 @@ // TODO: complete this | ||
median: function median(mu, sigma) { | ||
median: function median(mu/*, sigma*/) { | ||
return Math.exp(mu); | ||
@@ -542,11 +542,11 @@ }, | ||
mean : function(mean, std) { | ||
mean : function(mean/*, std*/) { | ||
return mean; | ||
}, | ||
median: function median(mean, std) { | ||
median: function median(mean/*, std*/) { | ||
return mean; | ||
}, | ||
mode: function (mean, std) { | ||
mode: function (mean/*, std*/) { | ||
return mean; | ||
@@ -594,3 +594,3 @@ }, | ||
mode: function mode(scale, shape) { | ||
mode: function mode(scale/*, shape*/) { | ||
return scale; | ||
@@ -632,7 +632,7 @@ }, | ||
median: function median(dof) { | ||
median: function median(/*dof*/) { | ||
return 0; | ||
}, | ||
mode: function mode(dof) { | ||
mode: function mode(/*dof*/) { | ||
return 0; | ||
@@ -684,3 +684,3 @@ }, | ||
sample: function sample(scale, shape) { | ||
return scale * Math.pow(-Math.log(Math.random()), 1 / shape); | ||
return scale * Math.pow(-Math.log(jStat._random_fn()), 1 / shape); | ||
}, | ||
@@ -722,3 +722,3 @@ | ||
mode: function mode(a, b) { | ||
mode: function mode(/*a, b*/) { | ||
throw new Error('mode is not yet implemented'); | ||
@@ -728,3 +728,3 @@ }, | ||
sample: function sample(a, b) { | ||
return (a / 2 + b / 2) + (b / 2 - a / 2) * (2 * Math.random() - 1); | ||
return (a / 2 + b / 2) + (b / 2 - a / 2) * (2 * jStat._random_fn() - 1); | ||
}, | ||
@@ -1005,3 +1005,3 @@ | ||
k++; | ||
p *= Math.random(); | ||
p *= jStat._random_fn(); | ||
} while (p > L); | ||
@@ -1072,3 +1072,3 @@ return k - 1; | ||
sample: function sample(a, b, c) { | ||
var u = Math.random(); | ||
var u = jStat._random_fn(); | ||
if (u < ((c - a) / (b - a))) | ||
@@ -1118,3 +1118,3 @@ return a + Math.sqrt(u * (b - a) * (c - a)) | ||
mode: function mode(a, b) { | ||
mode: function mode(/*a, b*/) { | ||
throw new Error('mode is not yet implemented'); | ||
@@ -1152,11 +1152,11 @@ }, | ||
mean: function(mu, b) { | ||
mean: function(mu/*, b*/) { | ||
return mu; | ||
}, | ||
median: function(mu, b) { | ||
median: function(mu/*, b*/) { | ||
return mu; | ||
}, | ||
mode: function(mu, b) { | ||
mode: function(mu/*, b*/) { | ||
return mu; | ||
@@ -1170,3 +1170,3 @@ }, | ||
sample: function sample(mu, b) { | ||
var u = Math.random() - 0.5; | ||
var u = jStat._random_fn() - 0.5; | ||
@@ -1173,0 +1173,0 @@ return mu - (b * laplaceSign(u) * Math.log(1 - (2 * Math.abs(u)))); |
@@ -151,6 +151,7 @@ /* Provides functions for the solution of linear system of equations, integration, extrapolation, | ||
var newarr = []; | ||
for (var i = 0; i < a.length; i++) { | ||
var i; | ||
for (i = 0; i < a.length; i++) { | ||
newarr.push(a[i].slice()); | ||
} | ||
for (var i = 0; i < newarr.length; i++) { | ||
for (i = 0; i < newarr.length; i++) { | ||
push.apply(newarr[i], b[i]); | ||
@@ -201,3 +202,3 @@ } | ||
} | ||
for (var i = 0; i < alen; i++) { | ||
for (i = 0; i < alen; i++) { | ||
for (j = 0; j < alen; j++) { | ||
@@ -212,3 +213,3 @@ vals[(mrow < 0) ? mrow + alen : mrow ] *= a[i][j]; | ||
} | ||
for (var i = 0; i < alen; i++) { | ||
for (i = 0; i < alen; i++) { | ||
result += vals[i]; | ||
@@ -233,3 +234,3 @@ } | ||
maug = a[0].length; | ||
for(var i = 0; i < n; i++) { | ||
for(i = 0; i < n; i++) { | ||
pivot = a[i][i]; | ||
@@ -257,3 +258,3 @@ j = i; | ||
} | ||
for (var i = n - 1; i >= 0; i--) { | ||
for (i = n - 1; i >= 0; i--) { | ||
sum = 0; | ||
@@ -269,10 +270,11 @@ for (j = i + 1; j<= n - 1; j++) { | ||
gauss_jordan: function gauss_jordan(a, b) { | ||
var m = jStat.aug(a, b), | ||
h = m.length, | ||
w = m[0].length; | ||
var m = jStat.aug(a, b); | ||
var h = m.length; | ||
var w = m[0].length; | ||
var c = 0; | ||
var x, y, y2; | ||
// find max pivot | ||
for (var y = 0; y < h; y++) { | ||
for (y = 0; y < h; y++) { | ||
var maxrow = y; | ||
for (var y2 = y+1; y2 < h; y2++) { | ||
for (y2 = y+1; y2 < h; y2++) { | ||
if (Math.abs(m[y2][y]) > Math.abs(m[maxrow][y])) | ||
@@ -284,5 +286,5 @@ maxrow = y2; | ||
m[maxrow] = tmp | ||
for (var y2 = y+1; y2 < h; y2++) { | ||
for (y2 = y+1; y2 < h; y2++) { | ||
c = m[y2][y] / m[y][y]; | ||
for (var x = y; x < w; x++) { | ||
for (x = y; x < w; x++) { | ||
m[y2][x] -= m[y][x] * c; | ||
@@ -293,6 +295,6 @@ } | ||
// backsubstitute | ||
for (var y = h-1; y >= 0; y--) { | ||
for (y = h-1; y >= 0; y--) { | ||
c = m[y][y]; | ||
for (var y2 = 0; y2 < y; y2++) { | ||
for (var x = w-1; x > y-1; x--) { | ||
for (y2 = 0; y2 < y; y2++) { | ||
for (x = w-1; x > y-1; x--) { | ||
m[y2][x] -= m[y][x] * m[y2][y] / c; | ||
@@ -302,3 +304,3 @@ } | ||
m[y][y] /= c; | ||
for (var x = h; x < w; x++) { | ||
for (x = h; x < w; x++) { | ||
m[y][x] /= c; | ||
@@ -392,3 +394,3 @@ } | ||
}); | ||
R[l][j] = A[i][j] - jStat.sum(parts); | ||
R[l][j] = A[parts.length][j] - jStat.sum(parts); | ||
}); | ||
@@ -574,31 +576,2 @@ }); | ||
function get_Q1(x) { | ||
var size = x.length; | ||
var norm_x = jStat.norm(x, 2); | ||
var e1 = jStat.zeros(1, size)[0]; | ||
e1[0] = 1; | ||
var u = jStat.add(jStat.multiply(jStat.multiply(e1, norm_x), -1), x); | ||
var norm_u = jStat.norm(u, 2); | ||
var v = jStat.divide(u, norm_u); | ||
var Q = jStat.subtract(jStat.identity(size), | ||
jStat.multiply(jStat.outer(v, v), 2)); | ||
return Q; | ||
} | ||
function qr(A) { | ||
var size = A[0].length; | ||
var QList = []; | ||
jStat.arange(size).forEach(function(i) { | ||
var x = jStat.slice(A, { row: { start: i }, col: i }); | ||
var Q = get_Q1(x); | ||
var Qn = jStat.identity(A.length); | ||
Qn = jStat.sliceAssign(Qn, { row: { start: i }, col: { start: i }}, Q); | ||
A = jStat.multiply(Qn, A); | ||
QList.push(Qn); | ||
}); | ||
var Q = QList.reduce(function(x, y){ return jStat.multiply(x,y) }); | ||
var R = A; | ||
return [Q, R]; | ||
} | ||
function qr2(x) { | ||
@@ -611,4 +584,4 @@ // quick impletation | ||
var r = jStat.zeros(p, p); | ||
x = jStat.copy(x); | ||
r = jStat.zeros(p, p); | ||
@@ -638,3 +611,3 @@ var i,j,k; | ||
lstsq: (function(A, b) { | ||
lstsq: (function() { | ||
// solve least squard problem for Ax=b as QR decomposition way if b is | ||
@@ -679,13 +652,13 @@ // [[b1],[b2],[b3]] form will return [[x1],[x2],[x3]] array form solution | ||
var RI = R_I(R1); | ||
var Q2 = jStat.transpose(Q1); | ||
var Q2 = jStat.transpose(Q1); | ||
if(Q2[0].length === undefined){ | ||
Q2 = [Q2]; // The confusing jStat.multifly implementation threat nature process again. | ||
} | ||
if(Q2[0].length === undefined){ | ||
Q2 = [Q2]; // The confusing jStat.multifly implementation threat nature process again. | ||
} | ||
var x = jStat.multiply(jStat.multiply(RI, Q2), b); | ||
if(x.length === undefined){ | ||
x = [[x]]; // The confusing jStat.multifly implementation threat nature process again. | ||
} | ||
if(x.length === undefined){ | ||
x = [[x]]; // The confusing jStat.multifly implementation threat nature process again. | ||
} | ||
@@ -703,3 +676,2 @@ | ||
var condition = 1; | ||
var count = 0; | ||
var n = a.length; | ||
@@ -711,7 +683,6 @@ var e = jStat.identity(n, n); | ||
while (condition === 1) { | ||
count++; | ||
maxim = a[0][1]; | ||
p = 0; | ||
q = 1; | ||
for (var i = 0; i < n; i++) { | ||
for (i = 0; i < n; i++) { | ||
for (j = 0; j < n; j++) { | ||
@@ -741,3 +712,3 @@ if (i != j) { | ||
condition = 0; | ||
for (var i = 1; i < n; i++) { | ||
for (i = 1; i < n; i++) { | ||
for (j = 1; j < n; j++) { | ||
@@ -750,3 +721,3 @@ if (i != j && Math.abs(a[i][j]) > 0.001) { | ||
} | ||
for (var i = 0; i < n; i++) ev.push(a[i][i]); | ||
for (i = 0; i < n; i++) ev.push(a[i][i]); | ||
//returns both the eigenvalue and eigenmatrix | ||
@@ -787,3 +758,3 @@ return [e, ev]; | ||
var g = []; | ||
var m, a1, j, k, I, d; | ||
var m, a1, j, k, I; | ||
while (i < order / 2) { | ||
@@ -823,8 +794,7 @@ I = f(a); | ||
} | ||
var n = X.length, | ||
h_min = Math.abs(x - X[pos(X, x) + 1]), | ||
i = 0, | ||
g = [], | ||
h1 = [], | ||
y1, y2, m, a, j; | ||
var h_min = Math.abs(x - X[pos(X, x) + 1]); | ||
var i = 0; | ||
var g = []; | ||
var h1 = []; | ||
var y1, y2, m, a, j; | ||
while (h >= h_min) { | ||
@@ -841,3 +811,3 @@ y1 = pos(X, x + h); | ||
for (j = 0; j < a - 1; j++) | ||
h1[j] = ((Math.pow(4, m)) * g[j + 1] - g[j]) / (Math.pow(4, m) - 1); | ||
h1[j] = ((Math.pow(4, m)) * g[j + 1] - g[j]) / (Math.pow(4, m) - 1); | ||
a = h1.length; | ||
@@ -923,7 +893,7 @@ g = h1; | ||
alpha[0] = 0; | ||
for (var i = 1; i < n - 1; i++) { | ||
for (i = 1; i < n - 1; i++) { | ||
alpha[i] = (3 / h[i]) * (F[i + 1] - F[i]) - | ||
(3 / h[i-1]) * (F[i] - F[i-1]); | ||
} | ||
for (var i = 1; i < n - 1; i++) { | ||
for (i = 1; i < n - 1; i++) { | ||
A[i] = []; | ||
@@ -956,3 +926,2 @@ B[i] = []; | ||
var n = X[0].length; | ||
var flag = false; | ||
var i = 0; | ||
@@ -970,6 +939,6 @@ var j, temp1; | ||
var Vt = []; | ||
for (var i = 0; i < m; i++) { | ||
for (i = 0; i < m; i++) { | ||
u[i] = jStat.sum(X[i]) / n; | ||
} | ||
for (var i = 0; i < n; i++) { | ||
for (i = 0; i < n; i++) { | ||
B[i] = []; | ||
@@ -981,3 +950,3 @@ for(j = 0; j < m; j++) { | ||
B = jStat.transpose(B); | ||
for (var i = 0; i < m; i++) { | ||
for (i = 0; i < m; i++) { | ||
C[i] = []; | ||
@@ -992,3 +961,3 @@ for (j = 0; j < m; j++) { | ||
Vt = jStat.transpose(V); | ||
for (var i = 0; i < D.length; i++) { | ||
for (i = 0; i < D.length; i++) { | ||
for (j = i; j < D.length; j++) { | ||
@@ -1006,3 +975,3 @@ if(D[i] < D[j]) { | ||
Bt = jStat.transpose(B); | ||
for (var i = 0; i < m; i++) { | ||
for (i = 0; i < m; i++) { | ||
Y[i] = []; | ||
@@ -1009,0 +978,0 @@ for (j = 0; j < Bt.length; j++) { |
jStat.models = (function(){ | ||
function sub_regress(endog, exog) { | ||
return ols(endog, exog); | ||
} | ||
function sub_regress(exog) { | ||
@@ -8,0 +3,0 @@ var var_count = exog[0].length; |
@@ -58,10 +58,11 @@ //To regress, simply build X matrix | ||
matrixmult: function matrixmult(A,B){ | ||
var i, j, k, result, sum; | ||
if (A.cols() == B.rows()) { | ||
if(B.rows()>1){ | ||
var result = []; | ||
for (var i = 0; i < A.rows(); i++) { | ||
result = []; | ||
for (i = 0; i < A.rows(); i++) { | ||
result[i] = []; | ||
for (var j = 0; j < B.cols(); j++) { | ||
var sum = 0; | ||
for (var k = 0; k < A.cols(); k++) { | ||
for (j = 0; j < B.cols(); j++) { | ||
sum = 0; | ||
for (k = 0; k < A.cols(); k++) { | ||
sum += A.toArray()[i][k] * B.toArray()[k][j]; | ||
@@ -74,8 +75,8 @@ } | ||
} | ||
var result = []; | ||
for (var i = 0; i < A.rows(); i++) { | ||
result = []; | ||
for (i = 0; i < A.rows(); i++) { | ||
result[i] = []; | ||
for (var j = 0; j < B.cols(); j++) { | ||
var sum = 0; | ||
for (var k = 0; k < A.cols(); k++) { | ||
for (j = 0; j < B.cols(); j++) { | ||
sum = 0; | ||
for (k = 0; k < A.cols(); k++) { | ||
sum += A.toArray()[i][k] * B.toArray()[j]; | ||
@@ -82,0 +83,0 @@ } |
@@ -35,3 +35,3 @@ // Special functions // | ||
var y = x; | ||
var i, z, yi, res, sum, ysq; | ||
var i, z, yi, res; | ||
if (y <= 0) { | ||
@@ -52,3 +52,3 @@ res = y % 1 + 3.6e-16; | ||
} | ||
for (var i = 0; i < 8; ++i) { | ||
for (i = 0; i < 8; ++i) { | ||
xnum = (xnum + p[i]) * z; | ||
@@ -61,3 +61,3 @@ xden = xden * z + q[i]; | ||
} else if (yi > y) { | ||
for (var i = 0; i < n; ++i) { | ||
for (i = 0; i < n; ++i) { | ||
res *= y; | ||
@@ -94,3 +94,3 @@ y++; | ||
var ITMAX = -~(Math.log((a >= 1) ? a : 1 / a) * 8.5 + a * 0.4 + 17); | ||
var an, endval; | ||
var an; | ||
@@ -400,3 +400,3 @@ if (x < 0 || a <= 0) { | ||
jStat.randn = function randn(n, m) { | ||
var u, v, x, y, q, mat; | ||
var u, v, x, y, q; | ||
if (!m) | ||
@@ -407,4 +407,4 @@ m = n; | ||
do { | ||
u = Math.random(); | ||
v = 1.7156 * (Math.random() - 0.5); | ||
u = jStat._random_fn(); | ||
v = 1.7156 * (jStat._random_fn() - 0.5); | ||
x = u - 0.449871; | ||
@@ -441,3 +441,3 @@ y = Math.abs(v) + 0.386595; | ||
v = v * v * v; | ||
u = Math.random(); | ||
u = jStat._random_fn(); | ||
} while(u > 1 - 0.331 * Math.pow(x, 4) && | ||
@@ -450,3 +450,3 @@ Math.log(u) > 0.5 * x*x + a1 * (1 - v + Math.log(v))); | ||
do { | ||
u = Math.random(); | ||
u = jStat._random_fn(); | ||
} while(u === 0); | ||
@@ -453,0 +453,0 @@ return Math.pow(u, 1 / oalph) * a1 * v; |
@@ -127,3 +127,3 @@ (function(jStat, Math) { | ||
tmpargs = new Array(args[0].length); | ||
for (var i = 0; i < args[0].length; i++) { | ||
for (i = 0; i < args[0].length; i++) { | ||
tmpargs[i] = args[0][i]; | ||
@@ -135,3 +135,3 @@ } | ||
sample = new Array(); | ||
for (var i = 0; i < args.length; i++) { | ||
for (i = 0; i < args.length; i++) { | ||
sample = sample.concat(args[i]); | ||
@@ -142,3 +142,3 @@ } | ||
expVar = 0; | ||
for (var i = 0; i < args.length; i++) { | ||
for (i = 0; i < args.length; i++) { | ||
expVar = expVar + args[i].length * Math.pow(jStat.mean(args[i]) - sampMean, 2); | ||
@@ -149,3 +149,3 @@ } | ||
unexpVar = 0; | ||
for (var i = 0; i < args.length; i++) { | ||
for (i = 0; i < args.length; i++) { | ||
sampSampMean = jStat.mean(args[i]); | ||
@@ -169,6 +169,6 @@ for (j = 0; j < args[i].length; j++) { | ||
} | ||
anovafscore = jStat.anovafscore(args); | ||
var anovafscore = jStat.anovafscore(args); | ||
df1 = args.length - 1; | ||
n = 0; | ||
for (var i = 0; i < args.length; i++) { | ||
for (i = 0; i < args.length; i++) { | ||
n = n + args[i].length; | ||
@@ -193,3 +193,3 @@ } | ||
var i; | ||
for (var i = 0; i < this.length; i++) { | ||
for (i = 0; i < this.length; i++) { | ||
n = n + this[i].length; | ||
@@ -196,0 +196,0 @@ } |
@@ -146,3 +146,3 @@ (function(jStat, Math) { | ||
var i; | ||
for (var i = 1; i < arrLen; i++) | ||
for (i = 1; i < arrLen; i++) | ||
diffs.push(arr[i] - arr[i - 1]); | ||
@@ -158,2 +158,3 @@ return diffs; | ||
var ranks = new Array(arrlen); | ||
var val; | ||
for (var i = 0; i < arrlen; i++) { | ||
@@ -163,5 +164,5 @@ var first = sorted.indexOf(arr[i]); | ||
if (first === last) { | ||
var val = first; | ||
val = first; | ||
} else { | ||
var val = (first + last) / 2; | ||
val = (first + last) / 2; | ||
} | ||
@@ -186,3 +187,3 @@ ranks[i] = val + 1; | ||
for (var i = 0; i < arrLen; i++) { | ||
for (i = 0; i < arrLen; i++) { | ||
if (_arr[i] === _arr[i + 1]) { | ||
@@ -303,3 +304,3 @@ count++; | ||
for (var i = 0; i < quantilesArray.length; i++) { | ||
for (i = 0; i < quantilesArray.length; i++) { | ||
p = quantilesArray[i]; | ||
@@ -342,3 +343,3 @@ m = alphap + p * (1 - alphap - betap); | ||
for (var i = 0; i < len; i++) { | ||
for (i = 0; i < len; i++) { | ||
value = arr[i]; | ||
@@ -356,5 +357,5 @@ if ((strict && value < score) || | ||
// Histogram (bin count) data | ||
jStat.histogram = function histogram(arr, bins) { | ||
jStat.histogram = function histogram(arr, binCnt) { | ||
binCnt = binCnt || 4; | ||
var first = jStat.min(arr); | ||
var binCnt = bins || 4; | ||
var binWidth = (jStat.max(arr) - first) / binCnt; | ||
@@ -365,5 +366,5 @@ var len = arr.length; | ||
for (var i = 0; i < binCnt; i++) | ||
for (i = 0; i < binCnt; i++) | ||
bins[i] = 0; | ||
for (var i = 0; i < len; i++) | ||
for (i = 0; i < len; i++) | ||
bins[Math.min(Math.floor(((arr[i] - first) / binWidth)), binCnt - 1)] += 1; | ||
@@ -383,3 +384,3 @@ | ||
for (var i = 0; i < arr1Len; i++) | ||
for (i = 0; i < arr1Len; i++) | ||
sq_dev[i] = (arr1[i] - u) * (arr2[i] - v); | ||
@@ -522,2 +523,3 @@ | ||
var args = Array.prototype.slice.call(arguments); | ||
var callbackFunction; | ||
@@ -527,3 +529,3 @@ // If the last argument is a function, we assume it's a callback; we | ||
if (isFunction(args[args.length - 1])) { | ||
var callbackFunction = args[args.length - 1]; | ||
callbackFunction = args[args.length - 1]; | ||
var argsToPass = args.slice(0, args.length - 1); | ||
@@ -539,3 +541,3 @@ | ||
} else { | ||
var callbackFunction = undefined; | ||
callbackFunction = undefined; | ||
var curriedFunction = function curriedFunction(vector) { | ||
@@ -542,0 +544,0 @@ return jStat[passfunc].apply(tmpthis, [vector].concat(args)); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
694667
15171