Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

distributions

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

distributions - npm Package Compare versions

Comparing version 1.1.0 to 2.0.0

8

distributions/binomial.js
var mathfn = require('mathfn');
var cephes = require('cephes');

@@ -33,4 +33,4 @@ function BinomialDistribution(properbility, size) {

// choose(n, x)
var binomialCoefficent = mathfn.gamma(n + 1) / (
mathfn.gamma(x + 1) * mathfn.gamma(n - x + 1)
var binomialCoefficent = cephes.gamma(n + 1) / (
cephes.gamma(x + 1) * cephes.gamma(n - x + 1)
)

@@ -42,3 +42,3 @@

BinomialDistribution.prototype.cdf = function (x) {
return mathfn.incBeta(1 - this._properbility, this._size - x, x + 1);
return cephes.bdtr(x, this._size, this._properbility);
};

@@ -45,0 +45,0 @@

var mathfn = require('mathfn');
var cephes = require('cephes');

@@ -34,7 +34,9 @@ function NormalDistribution(mean, sd) {

NormalDistribution.prototype.cdf = function (x) {
return 0.5 * (1 + mathfn.erf((x - this._mean) / Math.sqrt(2 * this._var)));
return cephes.ndtr((x - this._mean) / this._sd);
};
NormalDistribution.prototype.inv = function (p) {
return -Math.SQRT2 * this._sd * mathfn.invErfc(2 * p) + this._mean;
if (p <= 0) return -Infinity;
if (p >= 1) return Infinity;
return this._sd * cephes.ndtri(p) + this._mean;
};

@@ -41,0 +43,0 @@

var mathfn = require('mathfn');
var cephes = require('cephes');

@@ -18,3 +18,3 @@ function StudenttDistribution(df) {

this._pdf_const = (mathfn.gamma((df + 1) / 2) / (Math.sqrt(df * Math.PI) * mathfn.gamma(df / 2)));
this._pdf_const = (cephes.gamma((df + 1) / 2) / (Math.sqrt(df * Math.PI) * cephes.gamma(df / 2)));
this._pdf_exp = -((df + 1) / 2);

@@ -31,11 +31,9 @@

StudenttDistribution.prototype.cdf = function (x) {
var fac = Math.sqrt(x * x + this._df);
return mathfn.incBeta((x + fac) / (2 * fac), this._df_half, this._df_half);
return cephes.stdtr(this._df, x);
};
StudenttDistribution.prototype.inv = function (p) {
var fac = mathfn.invIncBeta(2 * Math.min(p, 1 - p), this._df_half, 0.5);
var y = Math.sqrt(this._df * (1 - fac) / fac);
return (p > 0.5) ? y : -y;
if (p <= 0) return -Infinity;
if (p >= 1) return Infinity;
return cephes.stdtri(this._df, p);
};

@@ -42,0 +40,0 @@

{
"name": "distributions",
"description": "A collection of probability distribution functions",
"version": "1.1.0",
"version": "2.0.0",
"author": "Andreas Madsen <amwebdk@gmail.com>",

@@ -21,8 +21,8 @@ "main": "./distributions.js",

"dependencies": {
"mathfn": "^1.0.0"
"cephes": "^1.1.2"
},
"devDependencies": {
"tap": "^6.3.0"
"tap": "^12.1.0"
},
"license": "MIT"
}

@@ -6,12 +6,13 @@

var last = s.map[i][ s.map[i].length - 1 ];
var ret = s.fn.apply(null, args);
if (Number.isFinite(last)) {
s.test.ok(
Math.abs( s.fn.apply(null, args) - last) < s.limit,
'almost absolute equal'
Math.abs(ret - last) < s.limit,
`is ${ret} almost absolute equal ${last}`
);
} else {
s.test.ok(
Object.is(s.fn.apply(null, args), last),
'exact equal'
Object.is(ret, last),
`is ${ret} equal ${last}`
);

@@ -18,0 +19,0 @@ }

@@ -176,4 +176,4 @@

t.equal(normal.variance(), 4);
t.end();
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc