Socket
Socket
Sign inDemoInstall

jstat

Package Overview
Dependencies
0
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.8.2 to 1.8.3

2

package.json
{
"name": "jstat",
"version": "1.8.2",
"version": "1.8.3",
"description": "Statistical Library for JavaScript",

@@ -5,0 +5,0 @@ "homepage": "http://github.com/jstat/jstat",

@@ -727,3 +727,31 @@ (function(jStat, Math) {

// Got this from http://www.math.ucla.edu/~tom/distributions/binomial.html
function betinc(x, a, b, eps) {
var a0 = 0;
var b0 = 1;
var a1 = 1;
var b1 = 1;
var m9 = 0;
var a2 = 0;
var c9;
while (Math.abs((a1 - a2) / a1) > eps) {
a2 = a1;
c9 = -(a + m9) * (a + b + m9) * x / (a + 2 * m9) / (a + 2 * m9 + 1);
a0 = a1 + c9 * a0;
b0 = b1 + c9 * b0;
m9 = m9 + 1;
c9 = m9 * (b - m9) * x / (a + 2 * m9 - 1) / (a + 2 * m9);
a1 = a0 + c9 * a1;
b1 = b0 + c9 * b1;
a0 = a0 / b1;
b0 = b0 / b1;
a1 = a1 / b1;
b1 = 1;
}
return a1 / a;
}
// extend uniform function with static methods

@@ -738,14 +766,26 @@ jStat.extend(jStat.binomial, {

cdf: function cdf(x, n, p) {
var binomarr = [],
k = 0;
if (x < 0) {
var betacdf;
var eps = 1e-10;
if (x < 0)
return 0;
}
if (x < n) {
for (; k <= x; k++) {
binomarr[ k ] = jStat.binomial.pdf(k, n, p);
}
return jStat.sum(binomarr);
}
return 1;
if (x >= n)
return 1;
if (p < 0 || p > 1 || n <= 0)
return NaN;
x = Math.floor(x);
var z = p;
var a = x + 1;
var b = n - x;
var s = a + b;
var bt = Math.exp(jStat.gammaln(s) - jStat.gammaln(b) -
jStat.gammaln(a) + a * Math.log(z) + b * Math.log(1 - z));
if (z < (a + 1) / (s + 2))
betacdf = bt * betinc(z, a, b, eps);
else
betacdf = 1 - bt * betinc(1 - z, b, a, eps);
return Math.round((1 - betacdf) * (1 / eps)) / (1 / eps);
}

@@ -752,0 +792,0 @@ });

@@ -23,2 +23,10 @@ var vows = require('vows');

assert.epsilon(tol, jStat.binomial.cdf(50, 1000, 0.05), 0.537529);
assert.ok(Number.isNaN(jStat.binomial.cdf(10, 12, -1)));
assert.ok(Number.isNaN(jStat.binomial.cdf(10, 12, 2)));
assert.equal(jStat.binomial.cdf(12, 10, 0.5), 1);
assert.equal(jStat.binomial.cdf(12, -1, 0.5), 1);
assert.epsilon(tol,
jStat.binomial.cdf(101073, 101184, 0.9988219676207195),
0.7857313651);
}

@@ -25,0 +33,0 @@ }

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc