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

simple-statistics

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-statistics - npm Package Compare versions

Comparing version 7.0.0 to 7.0.1

11

CHANGELOG.md

@@ -5,2 +5,13 @@ # Change Log

<a name="7.0.1"></a>
## [7.0.1](https://github.com/simple-statistics/simple-statistics/compare/v7.0.0...v7.0.1) (2019-02-07)
### Bug Fixes
* code format error ([a1b9f15](https://github.com/simple-statistics/simple-statistics/commit/a1b9f15))
* plus minus sign error ([f0b047d](https://github.com/simple-statistics/simple-statistics/commit/f0b047d))
<a name="7.0.0"></a>

@@ -7,0 +18,0 @@ # [7.0.0](https://github.com/simple-statistics/simple-statistics/compare/v6.1.1...v7.0.0) (2018-12-30)

2

dist/simple-statistics.js

@@ -1,2 +0,2 @@

function r(r){if(0===r.length)return 0;for(var t,e=r[0],n=0,o=1;o<r.length;o++)t=e+r[o],Math.abs(e)>=Math.abs(r[o])?n+=e-t+r[o]:n+=r[o]-t+e,e=t;return e+n}function t(t){if(0===t.length)throw new Error("mean requires at least one data point");return r(t)/t.length}function e(r,e){var n,o,a=t(r),i=0;if(2===e)for(o=0;o<r.length;o++)i+=(n=r[o]-a)*n;else for(o=0;o<r.length;o++)i+=Math.pow(r[o]-a,e);return i}function n(r){if(0===r.length)throw new Error("variance requires at least one data point");return e(r,2)/r.length}function o(r){if(1===r.length)return 0;var t=n(r);return Math.sqrt(t)}function a(r){if(0===r.length)throw new Error("mode requires at least one data point");if(1===r.length)return r[0];for(var t=r[0],e=NaN,n=0,o=1,a=1;a<r.length+1;a++)r[a]!==t?(o>n&&(n=o,e=t),o=1,t=r[a]):o++;return e}function i(r){return r.slice().sort(function(r,t){return r-t})}function h(r){if(0===r.length)throw new Error("min requires at least one data point");for(var t=r[0],e=1;e<r.length;e++)r[e]<t&&(t=r[e]);return t}function u(r){if(0===r.length)throw new Error("max requires at least one data point");for(var t=r[0],e=1;e<r.length;e++)r[e]>t&&(t=r[e]);return t}function f(r,t){var e=r.length*t;if(0===r.length)throw new Error("quantile requires at least one data point.");if(t<0||t>1)throw new Error("quantiles must be between 0 and 1");return 1===t?r[r.length-1]:0===t?r[0]:e%1!=0?r[Math.ceil(e)-1]:r.length%2==0?(r[e-1]+r[e])/2:r[e]}function s(r,t,e,n){for(e=e||0,n=n||r.length-1;n>e;){if(n-e>600){var o=n-e+1,a=t-e+1,i=Math.log(o),h=.5*Math.exp(2*i/3),u=.5*Math.sqrt(i*h*(o-h)/o);a-o/2<0&&(u*=-1),s(r,t,Math.max(e,Math.floor(t-a*h/o+u)),Math.min(n,Math.floor(t+(o-a)*h/o+u)))}var f=r[t],p=e,c=n;for(l(r,e,t),r[n]>f&&l(r,e,n);p<c;){for(l(r,p,c),p++,c--;r[p]<f;)p++;for(;r[c]>f;)c--}r[e]===f?l(r,e,c):l(r,++c,n),c<=t&&(e=c+1),t<=c&&(n=c-1)}}function l(r,t,e){var n=r[t];r[t]=r[e],r[e]=n}function p(r,t){var e=r.slice();if(Array.isArray(t)){!function(r,t){for(var e=[0],n=0;n<t.length;n++)e.push(v(r.length,t[n]));e.push(r.length-1),e.sort(g);var o=[0,e.length-1];for(;o.length;){var a=Math.ceil(o.pop()),i=Math.floor(o.pop());if(!(a-i<=1)){var h=Math.floor((i+a)/2);c(r,e[h],Math.floor(e[i]),Math.ceil(e[a])),o.push(i,h,h,a)}}}(e,t);for(var n=[],o=0;o<t.length;o++)n[o]=f(e,t[o]);return n}return c(e,v(e.length,t),0,e.length-1),f(e,t)}function c(r,t,e,n){t%1==0?s(r,t,e,n):(s(r,t=Math.floor(t),e,n),s(r,t+1,t+1,n))}function g(r,t){return r-t}function v(r,t){var e=r*t;return 1===t?r-1:0===t?0:e%1!=0?Math.ceil(e)-1:r%2==0?e-.5:e}function M(r,t){if(t<r[0])return 0;if(t>r[r.length-1])return 1;var e=function(r,t){var e=0,n=0,o=r.length;for(;n<o;)t<=r[e=n+o>>>1]?o=e:n=-~e;return n}(r,t);if(r[e]!==t)return e/r.length;e++;var n=function(r,t){var e=0,n=0,o=r.length;for(;n<o;)t>=r[e=n+o>>>1]?n=-~e:o=e;return n}(r,t);if(n===e)return e/r.length;var o=n-e+1;return o*(n+e)/2/o/r.length}function w(r){var t=p(r,.75),e=p(r,.25);if("number"==typeof t&&"number"==typeof e)return t-e}function x(r){return+p(r,.5)}function q(r){for(var t=x(r),e=[],n=0;n<r.length;n++)e.push(Math.abs(r[n]-t));return x(e)}function d(r,t){t=t||Math.random;for(var e,n,o=r.length;o>0;)n=Math.floor(t()*o--),e=r[o],r[o]=r[n],r[n]=e;return r}function m(r,t){return d(r.slice().slice(),t)}function b(r){for(var t,e=0,n=0;n<r.length;n++)0!==n&&r[n]===t||(t=r[n],e++);return e}function y(r,t){for(var e=[],n=0;n<r;n++){for(var o=[],a=0;a<t;a++)o.push(0);e.push(o)}return e}function E(r,t,e,n){var o;if(r>0){var a=(e[t]-e[r-1])/(t-r+1);o=n[t]-n[r-1]-(t-r+1)*a*a}else o=n[t]-e[t]*e[t]/(t+1);return o<0?0:o}function I(r,t,e,n,o,a,i){if(!(r>t)){var h=Math.floor((r+t)/2);n[e][h]=n[e-1][h-1],o[e][h]=h;var u=e;r>e&&(u=Math.max(u,o[e][r-1]||0)),u=Math.max(u,o[e-1][h]||0);var f,s,l,p=h-1;t<n.length-1&&(p=Math.min(p,o[e][t+1]||0));for(var c=p;c>=u&&!((f=E(c,h,a,i))+n[e-1][u-1]>=n[e][h]);--c)(s=E(u,h,a,i)+n[e-1][u-1])<n[e][h]&&(n[e][h]=s,o[e][h]=u),u++,(l=f+n[e-1][c-1])<n[e][h]&&(n[e][h]=l,o[e][h]=c);I(r,h-1,e,n,o,a,i),I(h+1,t,e,n,o,a,i)}}function P(r,e){if(r.length!==e.length)throw new Error("sampleCovariance requires samples with equal lengths");if(r.length<2)throw new Error("sampleCovariance requires at least two data points in each sample");for(var n=t(r),o=t(e),a=0,i=0;i<r.length;i++)a+=(r[i]-n)*(e[i]-o);return a/(r.length-1)}function C(r){if(r.length<2)throw new Error("sampleVariance requires at least two data points");return e(r,2)/(r.length-1)}function N(r){var t=C(r);return Math.sqrt(t)}function R(r,t,e,n){return(r*t+e*n)/(t+n)}function D(r){if(0===r.length)throw new Error("rootMeanSquare requires at least one data point");for(var t=0,e=0;e<r.length;e++)t+=Math.pow(r[e],2);return Math.sqrt(t/r.length)}var A=function(){this.totalCount=0,this.data={}};A.prototype.train=function(r,t){for(var e in this.data[t]||(this.data[t]={}),r){var n=r[e];void 0===this.data[t][e]&&(this.data[t][e]={}),void 0===this.data[t][e][n]&&(this.data[t][e][n]=0),this.data[t][e][n]++}this.totalCount++},A.prototype.score=function(r){var t,e={};for(var n in r){var o=r[n];for(t in this.data)e[t]={},e[t][n+"_"+o]=this.data[t][n]?(this.data[t][n][o]||0)/this.totalCount:0}var a={};for(t in e)for(var i in a[t]=0,e[t])a[t]+=e[t][i];return a};var S=function(){this.weights=[],this.bias=0};S.prototype.predict=function(r){if(r.length!==this.weights.length)return null;for(var t=0,e=0;e<this.weights.length;e++)t+=this.weights[e]*r[e];return(t+=this.bias)>0?1:0},S.prototype.train=function(r,t){if(0!==t&&1!==t)return null;r.length!==this.weights.length&&(this.weights=r,this.bias=1);var e=this.predict(r);if("number"==typeof e&&e!==t){for(var n=t-e,o=0;o<this.weights.length;o++)this.weights[o]+=n*r[o];this.bias+=n}return this};var T=1e-4;function _(r){if(r<0)throw new Error("factorial requires a non-negative value");if(Math.floor(r)!==r)throw new Error("factorial requires an integer input");for(var t=1,e=2;e<=r;e++)t*=e;return t}var z=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],B=607/128,K=Math.log(Math.sqrt(2*Math.PI));var U={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}};var G=Math.sqrt(2*Math.PI),H={gaussian:function(r){return Math.exp(-.5*r*r)/G}},W={nrd:function(r){var t=N(r),e=w(r);return"number"==typeof e&&(t=Math.min(t,e/1.34)),1.06*t*Math.pow(r.length,-.2)}};function J(r,t,e){var n,o;if(void 0===t)n=H.gaussian;else if("string"==typeof t){if(!H[t])throw new Error('Unknown kernel "'+t+'"');n=H[t]}else n=t;if(void 0===e)o=W.nrd(r);else if("string"==typeof e){if(!W[e])throw new Error('Unknown bandwidth method "'+e+'"');o=W[e](r)}else o=e;return function(t){var e=0,a=0;for(e=0;e<r.length;e++)a+=n((t-r[e])/o);return a/o/r.length}}var Q=Math.sqrt(2*Math.PI);function Y(r){for(var t=r,e=r,n=1;n<15;n++)t+=e*=r*r/(2*n+1);return Math.round(1e4*(.5+t/Q*Math.exp(-r*r/2)))/1e4}for(var Z=[],L=0;L<=3.09;L+=.01)Z.push(Y(L));function O(r){var t=1/(1+.5*Math.abs(r)),e=t*Math.exp(-Math.pow(r,2)-1.26551223+1.00002368*t+.37409196*Math.pow(t,2)+.09678418*Math.pow(t,3)-.18628806*Math.pow(t,4)+.27886807*Math.pow(t,5)-1.13520398*Math.pow(t,6)+1.48851587*Math.pow(t,7)-.82215223*Math.pow(t,8)+.17087277*Math.pow(t,9));return r>=0?1-e:e-1}function V(r){var t=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),e=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*t)+Math.log(1-r*r)/2,2)-Math.log(1-r*r)/t)-(2/(Math.PI*t)+Math.log(1-r*r)/2));return r>=0?e:-e}function X(r){if("number"==typeof r)return r<0?-1:0===r?0:1;throw new TypeError("not a number")}exports.linearRegression=function(r){var t,e,n=r.length;if(1===n)t=0,e=r[0][1];else{for(var o,a,i,h=0,u=0,f=0,s=0,l=0;l<n;l++)h+=a=(o=r[l])[0],u+=i=o[1],f+=a*a,s+=a*i;e=u/n-(t=(n*s-h*u)/(n*f-h*h))*h/n}return{m:t,b:e}},exports.linearRegressionLine=function(r){return function(t){return r.b+r.m*t}},exports.standardDeviation=o,exports.rSquared=function(r,t){if(r.length<2)return 1;for(var e=0,n=0;n<r.length;n++)e+=r[n][1];for(var o=e/r.length,a=0,i=0;i<r.length;i++)a+=Math.pow(o-r[i][1],2);for(var h=0,u=0;u<r.length;u++)h+=Math.pow(r[u][1]-t(r[u][0]),2);return 1-h/a},exports.mode=function(r){return a(i(r))},exports.modeFast=function(r){for(var t,e=new Map,n=0,o=0;o<r.length;o++){var a=e.get(r[o]);void 0===a?a=1:a++,a>n&&(t=r[o],n=a),e.set(r[o],a)}if(0===n)throw new Error("mode requires at last one data point");return t},exports.modeSorted=a,exports.min=h,exports.max=u,exports.extent=function(r){if(0===r.length)throw new Error("extent requires at least one data point");for(var t=r[0],e=r[0],n=1;n<r.length;n++)r[n]>e&&(e=r[n]),r[n]<t&&(t=r[n]);return[t,e]},exports.minSorted=function(r){return r[0]},exports.maxSorted=function(r){return r[r.length-1]},exports.extentSorted=function(r){return[r[0],r[r.length-1]]},exports.sum=r,exports.sumSimple=function(r){for(var t=0,e=0;e<r.length;e++)t+=r[e];return t},exports.product=function(r){for(var t=1,e=0;e<r.length;e++)t*=r[e];return t},exports.quantile=p,exports.quantileSorted=f,exports.quantileRank=function(r,t){return M(i(r),t)},exports.quantileRankSorted=M,exports.interquartileRange=w,exports.iqr=w,exports.medianAbsoluteDeviation=q,exports.mad=q,exports.chunk=function(r,t){var e=[];if(t<1)throw new Error("chunk size must be a positive number");if(Math.floor(t)!==t)throw new Error("chunk size must be an integer");for(var n=0;n<r.length;n+=t)e.push(r.slice(n,n+t));return e},exports.sampleWithReplacement=function(r,t,e){if(0===r.length)return[];e=e||Math.random;for(var n=r.length,o=[],a=0;a<t;a++){var i=Math.floor(e()*n);o.push(r[i])}return o},exports.shuffle=m,exports.shuffleInPlace=d,exports.sample=function(r,t,e){return m(r,e).slice(0,t)},exports.ckmeans=function(r,t){if(t>r.length)throw new Error("cannot generate more classes than there are data values");var e=i(r);if(1===b(e))return[e];var n=y(t,e.length),o=y(t,e.length);!function(r,t,e){for(var n=t[0].length,o=r[Math.floor(n/2)],a=[],i=[],h=0,u=void 0;h<n;++h)u=r[h]-o,0===h?(a.push(u),i.push(u*u)):(a.push(a[h-1]+u),i.push(i[h-1]+u*u)),t[0][h]=E(0,h,a,i),e[0][h]=0;for(var f=1;f<t.length;++f)I(f<t.length-1?f:n-1,n-1,f,t,e,a,i)}(e,n,o);for(var a=[],h=o[0].length-1,u=o.length-1;u>=0;u--){var f=o[u][h];a[u]=e.slice(f,h+1),u>0&&(h=f-1)}return a},exports.uniqueCountSorted=b,exports.sumNthPowerDeviations=e,exports.equalIntervalBreaks=function(r,t){if(r.length<2)return r;for(var e=h(r),n=u(r),o=[e],a=(n-e)/t,i=1;i<t;i++)o.push(o[0]+a*i);return o.push(n),o},exports.sampleCovariance=P,exports.sampleCorrelation=function(r,t){return P(r,t)/N(r)/N(t)},exports.sampleVariance=C,exports.sampleStandardDeviation=N,exports.sampleSkewness=function(r){if(r.length<3)throw new Error("sampleSkewness requires at least three data points");for(var e,n=t(r),o=0,a=0,i=0;i<r.length;i++)o+=(e=r[i]-n)*e,a+=e*e*e;var h=Math.sqrt(o/(r.length-1)),u=r.length;return u*a/((u-1)*(u-2)*Math.pow(h,3))},exports.sampleKurtosis=function(r){var e=r.length;if(e<4)throw new Error("sampleKurtosis requires at least four data points");for(var n,o=t(r),a=0,i=0,h=0;h<e;h++)a+=(n=r[h]-o)*n,i+=n*n*n*n;return(e-1)/((e-2)*(e-3))*(e*(e+1)*i/(a*a)-3*(e-1))},exports.permutationsHeap=function(r){for(var t=new Array(r.length),e=[r.slice()],n=0;n<r.length;n++)t[n]=0;for(var o=0;o<r.length;)if(t[o]<o){var a=0;o%2!=0&&(a=t[o]);var i=r[a];r[a]=r[o],r[o]=i,e.push(r.slice()),t[o]++,o=0}else t[o]=0,o++;return e},exports.combinations=function r(t,e){var n,o,a,i,h=[];for(n=0;n<t.length;n++)if(1===e)h.push([t[n]]);else for(a=r(t.slice(n+1,t.length),e-1),o=0;o<a.length;o++)(i=a[o]).unshift(t[n]),h.push(i);return h},exports.combinationsReplacement=function r(t,e){for(var n=[],o=0;o<t.length;o++)if(1===e)n.push([t[o]]);else for(var a=r(t.slice(o,t.length),e-1),i=0;i<a.length;i++)n.push([t[o]].concat(a[i]));return n},exports.addToMean=function(r,t,e){return r+(e-r)/(t+1)},exports.combineMeans=R,exports.combineVariances=function(r,t,e,n,o,a){var i=R(t,e,o,a);return(e*(r+Math.pow(t-i,2))+a*(n+Math.pow(o-i,2)))/(e+a)},exports.geometricMean=function(r){if(0===r.length)throw new Error("geometricMean requires at least one data point");for(var t=1,e=0;e<r.length;e++){if(r[e]<=0)throw new Error("geometricMean requires only positive numbers as input");t*=r[e]}return Math.pow(t,1/r.length)},exports.harmonicMean=function(r){if(0===r.length)throw new Error("harmonicMean requires at least one data point");for(var t=0,e=0;e<r.length;e++){if(r[e]<=0)throw new Error("harmonicMean requires only positive numbers as input");t+=1/r[e]}return r.length/t},exports.average=t,exports.mean=t,exports.median=x,exports.medianSorted=function(r){return f(r,.5)},exports.subtractFromMean=function(r,t,e){return(r*t-e)/(t-1)},exports.rootMeanSquare=D,exports.rms=D,exports.variance=n,exports.tTest=function(r,e){return(t(r)-e)/(o(r)/Math.sqrt(r.length))},exports.tTestTwoSample=function(r,e,n){var o=r.length,a=e.length;if(!o||!a)return null;n||(n=0);var i=t(r),h=t(e),u=C(r),f=C(e);return"number"==typeof i&&"number"==typeof h&&"number"==typeof u&&"number"==typeof f?(i-h-n)/Math.sqrt(((o-1)*u+(a-1)*f)/(o+a-2)*(1/o+1/a)):void 0},exports.BayesianClassifier=A,exports.bayesian=A,exports.PerceptronModel=S,exports.perceptron=S,exports.epsilon=T,exports.factorial=_,exports.gamma=function r(t){if(Number.isInteger(t))return t<=0?NaN:_(t-1);if(--t<0)return Math.PI/(Math.sin(Math.PI*-t)*r(-t));var e=t+.25;return Math.pow(t/Math.E,t)*Math.sqrt(2*Math.PI*(t+1/6))*(1+1/144/Math.pow(e,2)-1/12960/Math.pow(e,3)-257/207360/Math.pow(e,4)-52/2612736/Math.pow(e,5)+5741173/9405849600/Math.pow(e,6)+37529/18811699200/Math.pow(e,7))},exports.gammaln=function(r){if(r<=0)return Infinity;r--;for(var t=z[0],e=1;e<15;e++)t+=z[e]/(r+e);var n=B+.5+r;return K+Math.log(t)-n+(r+.5)*Math.log(n)},exports.bernoulliDistribution=function(r){if(r<0||r>1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-r,r]},exports.binomialDistribution=function(r,t){if(!(t<0||t>1||r<=0||r%1!=0)){var e=0,n=0,o=[],a=1;do{o[e]=a*Math.pow(t,e)*Math.pow(1-t,r-e),n+=o[e],a=a*(r-++e+1)/e}while(n<1-T);return o}},exports.poissonDistribution=function(r){if(!(r<=0)){var t=0,e=0,n=[],o=1;do{n[t]=Math.exp(-r)*Math.pow(r,t)/o,e+=n[t],o*=++t}while(e<1-T);return n}},exports.chiSquaredDistributionTable=U,exports.chiSquaredGoodnessOfFit=function(r,e,n){for(var o=0,a=e(t(r)),i=[],h=[],u=0;u<r.length;u++)void 0===i[r[u]]&&(i[r[u]]=0),i[r[u]]++;for(var f=0;f<i.length;f++)void 0===i[f]&&(i[f]=0);for(var s in a)s in i&&(h[+s]=a[s]*r.length);for(var l=h.length-1;l>=0;l--)h[l]<3&&(h[l-1]+=h[l],h.pop(),i[l-1]+=i[l],i.pop());for(var p=0;p<i.length;p++)o+=Math.pow(i[p]-h[p],2)/h[p];return U[i.length-1-1][n]<o},exports.kernelDensityEstimation=J,exports.kde=J,exports.zScore=function(r,t,e){return(r-t)/e},exports.cumulativeStdNormalProbability=function(r){var t=Math.abs(r),e=Math.min(Math.round(100*t),Z.length-1);return r>=0?Z[e]:+(1-Z[e]).toFixed(4)},exports.standardNormalTable=Z,exports.errorFunction=O,exports.erf=O,exports.inverseErrorFunction=V,exports.probit=function(r){return 0===r?r=T:r>=1&&(r=1-T),Math.sqrt(2)*V(2*r-1)},exports.permutationTest=function(r,e,n,o){if(void 0===o&&(o=1e4),void 0===n&&(n="two_side"),"two_side"!==n&&"greater"!==n&&"less"!==n)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'");for(var a=t(r)-t(e),i=new Array(o),h=r.concat(e),u=Math.floor(h.length/2),f=0;f<o;f++){d(h);var s=h.slice(0,u),l=h.slice(u,h.length),p=t(s)-t(l);i[f]=p}var c=0;if("two_side"===n)for(var g=0;g<=o;g++)Math.abs(i[g])>=Math.abs(a)&&(c+=1);else if("greater"===n)for(var v=0;v<=o;v++)i[v]>=a&&(c+=1);else for(var M=0;M<=o;M++)i[M]<=a&&(c+=1);return c/o},exports.bisect=function(r,t,e,n,o){if("function"!=typeof r)throw new TypeError("func must be a function");for(var a=0;a<n;a++){var i=(t+e)/2;if(0===r(i)||Math.abs((e-t)/2)<o)return i;X(r(i))===X(r(t))?t=i:e=i}throw new Error("maximum number of iterations exceeded")},exports.quickselect=s,exports.sign=X,exports.numericSort=i;
function t(t){if(0===t.length)return 0;for(var r,e=t[0],n=0,o=1;o<t.length;o++)r=e+t[o],Math.abs(e)>=Math.abs(t[o])?n+=e-r+t[o]:n+=t[o]-r+e,e=r;return e+n}function r(r){if(0===r.length)throw new Error("mean requires at least one data point");return t(r)/r.length}function e(t,e){var n,o,a=r(t),i=0;if(2===e)for(o=0;o<t.length;o++)i+=(n=t[o]-a)*n;else for(o=0;o<t.length;o++)i+=Math.pow(t[o]-a,e);return i}function n(t){if(0===t.length)throw new Error("variance requires at least one data point");return e(t,2)/t.length}function o(t){if(1===t.length)return 0;var r=n(t);return Math.sqrt(r)}function a(t){if(0===t.length)throw new Error("mode requires at least one data point");if(1===t.length)return t[0];for(var r=t[0],e=NaN,n=0,o=1,a=1;a<t.length+1;a++)t[a]!==r?(o>n&&(n=o,e=r),o=1,r=t[a]):o++;return e}function i(t){return t.slice().sort(function(t,r){return t-r})}function s(t){if(0===t.length)throw new Error("min requires at least one data point");for(var r=t[0],e=1;e<t.length;e++)t[e]<r&&(r=t[e]);return r}function u(t){if(0===t.length)throw new Error("max requires at least one data point");for(var r=t[0],e=1;e<t.length;e++)t[e]>r&&(r=t[e]);return r}function h(t,r){var e=t.length*r;if(0===t.length)throw new Error("quantile requires at least one data point.");if(r<0||r>1)throw new Error("quantiles must be between 0 and 1");return 1===r?t[t.length-1]:0===r?t[0]:e%1!=0?t[Math.ceil(e)-1]:t.length%2==0?(t[e-1]+t[e])/2:t[e]}function f(t,r,e,n){for(e=e||0,n=n||t.length-1;n>e;){if(n-e>600){var o=n-e+1,a=r-e+1,i=Math.log(o),s=.5*Math.exp(2*i/3),u=.5*Math.sqrt(i*s*(o-s)/o);a-o/2<0&&(u*=-1),f(t,r,Math.max(e,Math.floor(r-a*s/o+u)),Math.min(n,Math.floor(r+(o-a)*s/o+u)))}var h=t[r],p=e,c=n;for(l(t,e,r),t[n]>h&&l(t,e,n);p<c;){for(l(t,p,c),p++,c--;t[p]<h;)p++;for(;t[c]>h;)c--}t[e]===h?l(t,e,c):l(t,++c,n),c<=r&&(e=c+1),r<=c&&(n=c-1)}}function l(t,r,e){var n=t[r];t[r]=t[e],t[e]=n}function p(t,r){var e=t.slice();if(Array.isArray(r)){!function(t,r){for(var e=[0],n=0;n<r.length;n++)e.push(v(t.length,r[n]));e.push(t.length-1),e.sort(g);var o=[0,e.length-1];for(;o.length;){var a=Math.ceil(o.pop()),i=Math.floor(o.pop());if(!(a-i<=1)){var s=Math.floor((i+a)/2);c(t,e[s],Math.floor(e[i]),Math.ceil(e[a])),o.push(i,s,s,a)}}}(e,r);for(var n=[],o=0;o<r.length;o++)n[o]=h(e,r[o]);return n}return c(e,v(e.length,r),0,e.length-1),h(e,r)}function c(t,r,e,n){r%1==0?f(t,r,e,n):(f(t,r=Math.floor(r),e,n),f(t,r+1,r+1,n))}function g(t,r){return t-r}function v(t,r){var e=t*r;return 1===r?t-1:0===r?0:e%1!=0?Math.ceil(e)-1:t%2==0?e-.5:e}function w(t,r){if(r<t[0])return 0;if(r>t[t.length-1])return 1;var e=function(t,r){var e=0,n=0,o=t.length;for(;n<o;)r<=t[e=n+o>>>1]?o=e:n=-~e;return n}(t,r);if(t[e]!==r)return e/t.length;e++;var n=function(t,r){var e=0,n=0,o=t.length;for(;n<o;)r>=t[e=n+o>>>1]?n=-~e:o=e;return n}(t,r);if(n===e)return e/t.length;var o=n-e+1;return o*(n+e)/2/o/t.length}function M(t){var r=p(t,.75),e=p(t,.25);if("number"==typeof r&&"number"==typeof e)return r-e}function x(t){return+p(t,.5)}function m(t){for(var r=x(t),e=[],n=0;n<t.length;n++)e.push(Math.abs(t[n]-r));return x(e)}function d(t,r){r=r||Math.random;for(var e,n,o=t.length;o>0;)n=Math.floor(r()*o--),e=t[o],t[o]=t[n],t[n]=e;return t}function b(t,r){return d(t.slice().slice(),r)}function q(t){for(var r,e=0,n=0;n<t.length;n++)0!==n&&t[n]===r||(r=t[n],e++);return e}function E(t,r){for(var e=[],n=0;n<t;n++){for(var o=[],a=0;a<r;a++)o.push(0);e.push(o)}return e}function y(t,r,e,n){var o;if(t>0){var a=(e[r]-e[t-1])/(r-t+1);o=n[r]-n[t-1]-(r-t+1)*a*a}else o=n[r]-e[r]*e[r]/(r+1);return o<0?0:o}function S(t,r,e,n,o,a,i){if(!(t>r)){var s=Math.floor((t+r)/2);n[e][s]=n[e-1][s-1],o[e][s]=s;var u=e;t>e&&(u=Math.max(u,o[e][t-1]||0)),u=Math.max(u,o[e-1][s]||0);var h,f,l,p=s-1;r<n.length-1&&(p=Math.min(p,o[e][r+1]||0));for(var c=p;c>=u&&!((h=y(c,s,a,i))+n[e-1][u-1]>=n[e][s]);--c)(f=y(u,s,a,i)+n[e-1][u-1])<n[e][s]&&(n[e][s]=f,o[e][s]=u),u++,(l=h+n[e-1][c-1])<n[e][s]&&(n[e][s]=l,o[e][s]=c);S(t,s-1,e,n,o,a,i),S(s+1,r,e,n,o,a,i)}}function k(t,e){if(t.length!==e.length)throw new Error("sampleCovariance requires samples with equal lengths");if(t.length<2)throw new Error("sampleCovariance requires at least two data points in each sample");for(var n=r(t),o=r(e),a=0,i=0;i<t.length;i++)a+=(t[i]-n)*(e[i]-o);return a/(t.length-1)}function I(t){if(t.length<2)throw new Error("sampleVariance requires at least two data points");return e(t,2)/(t.length-1)}function P(t){var r=I(t);return Math.sqrt(r)}function D(t,r,e,n){return(t*r+e*n)/(r+n)}function C(t){if(0===t.length)throw new Error("rootMeanSquare requires at least one data point");for(var r=0,e=0;e<t.length;e++)r+=Math.pow(t[e],2);return Math.sqrt(r/t.length)}var T=function(){this.totalCount=0,this.data={}};T.prototype.train=function(t,r){for(var e in this.data[r]||(this.data[r]={}),t){var n=t[e];void 0===this.data[r][e]&&(this.data[r][e]={}),void 0===this.data[r][e][n]&&(this.data[r][e][n]=0),this.data[r][e][n]++}this.totalCount++},T.prototype.score=function(t){var r,e={};for(var n in t){var o=t[n];for(r in this.data)e[r]={},e[r][n+"_"+o]=this.data[r][n]?(this.data[r][n][o]||0)/this.totalCount:0}var a={};for(r in e)for(var i in a[r]=0,e[r])a[r]+=e[r][i];return a};var N=function(){this.weights=[],this.bias=0};N.prototype.predict=function(t){if(t.length!==this.weights.length)return null;for(var r=0,e=0;e<this.weights.length;e++)r+=this.weights[e]*t[e];return(r+=this.bias)>0?1:0},N.prototype.train=function(t,r){if(0!==r&&1!==r)return null;t.length!==this.weights.length&&(this.weights=t,this.bias=1);var e=this.predict(t);if("number"==typeof e&&e!==r){for(var n=r-e,o=0;o<this.weights.length;o++)this.weights[o]+=n*t[o];this.bias+=n}return this};var R=1e-4;function F(t){if(t<0)throw new Error("factorial requires a non-negative value");if(Math.floor(t)!==t)throw new Error("factorial requires an integer input");for(var r=1,e=2;e<=t;e++)r*=e;return r}var A=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],_=607/128,z=Math.log(Math.sqrt(2*Math.PI));var V={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}};var B=Math.sqrt(2*Math.PI),K={gaussian:function(t){return Math.exp(-.5*t*t)/B}},U={nrd:function(t){var r=P(t),e=M(t);return"number"==typeof e&&(r=Math.min(r,e/1.34)),1.06*r*Math.pow(t.length,-.2)}};function G(t,r,e){var n,o;if(void 0===r)n=K.gaussian;else if("string"==typeof r){if(!K[r])throw new Error('Unknown kernel "'+r+'"');n=K[r]}else n=r;if(void 0===e)o=U.nrd(t);else if("string"==typeof e){if(!U[e])throw new Error('Unknown bandwidth method "'+e+'"');o=U[e](t)}else o=e;return function(r){var e=0,a=0;for(e=0;e<t.length;e++)a+=n((r-t[e])/o);return a/o/t.length}}var H=Math.sqrt(2*Math.PI);function L(t){for(var r=t,e=t,n=1;n<15;n++)r+=e*=t*t/(2*n+1);return Math.round(1e4*(.5+r/H*Math.exp(-t*t/2)))/1e4}for(var O=[],W=0;W<=3.09;W+=.01)O.push(L(W));function j(t){var r=1/(1+.5*Math.abs(t)),e=r*Math.exp(-t*t+((((((((.17087277*r-.82215223)*r+1.48851587)*r-1.13520398)*r+.27886807)*r-.18628806)*r+.09678418)*r+.37409196)*r+1.00002368)*r-1.26551223);return t>=0?1-e:e-1}function J(t){var r=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),e=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*r)+Math.log(1-t*t)/2,2)-Math.log(1-t*t)/r)-(2/(Math.PI*r)+Math.log(1-t*t)/2));return t>=0?e:-e}function Q(t){if("number"==typeof t)return t<0?-1:0===t?0:1;throw new TypeError("not a number")}exports.linearRegression=function(t){var r,e,n=t.length;if(1===n)r=0,e=t[0][1];else{for(var o,a,i,s=0,u=0,h=0,f=0,l=0;l<n;l++)s+=a=(o=t[l])[0],u+=i=o[1],h+=a*a,f+=a*i;e=u/n-(r=(n*f-s*u)/(n*h-s*s))*s/n}return{m:r,b:e}},exports.linearRegressionLine=function(t){return function(r){return t.b+t.m*r}},exports.standardDeviation=o,exports.rSquared=function(t,r){if(t.length<2)return 1;for(var e=0,n=0;n<t.length;n++)e+=t[n][1];for(var o=e/t.length,a=0,i=0;i<t.length;i++)a+=Math.pow(o-t[i][1],2);for(var s=0,u=0;u<t.length;u++)s+=Math.pow(t[u][1]-r(t[u][0]),2);return 1-s/a},exports.mode=function(t){return a(i(t))},exports.modeFast=function(t){for(var r,e=new Map,n=0,o=0;o<t.length;o++){var a=e.get(t[o]);void 0===a?a=1:a++,a>n&&(r=t[o],n=a),e.set(t[o],a)}if(0===n)throw new Error("mode requires at last one data point");return r},exports.modeSorted=a,exports.min=s,exports.max=u,exports.extent=function(t){if(0===t.length)throw new Error("extent requires at least one data point");for(var r=t[0],e=t[0],n=1;n<t.length;n++)t[n]>e&&(e=t[n]),t[n]<r&&(r=t[n]);return[r,e]},exports.minSorted=function(t){return t[0]},exports.maxSorted=function(t){return t[t.length-1]},exports.extentSorted=function(t){return[t[0],t[t.length-1]]},exports.sum=t,exports.sumSimple=function(t){for(var r=0,e=0;e<t.length;e++)r+=t[e];return r},exports.product=function(t){for(var r=1,e=0;e<t.length;e++)r*=t[e];return r},exports.quantile=p,exports.quantileSorted=h,exports.quantileRank=function(t,r){return w(i(t),r)},exports.quantileRankSorted=w,exports.interquartileRange=M,exports.iqr=M,exports.medianAbsoluteDeviation=m,exports.mad=m,exports.chunk=function(t,r){var e=[];if(r<1)throw new Error("chunk size must be a positive number");if(Math.floor(r)!==r)throw new Error("chunk size must be an integer");for(var n=0;n<t.length;n+=r)e.push(t.slice(n,n+r));return e},exports.sampleWithReplacement=function(t,r,e){if(0===t.length)return[];e=e||Math.random;for(var n=t.length,o=[],a=0;a<r;a++){var i=Math.floor(e()*n);o.push(t[i])}return o},exports.shuffle=b,exports.shuffleInPlace=d,exports.sample=function(t,r,e){return b(t,e).slice(0,r)},exports.ckmeans=function(t,r){if(r>t.length)throw new Error("cannot generate more classes than there are data values");var e=i(t);if(1===q(e))return[e];var n=E(r,e.length),o=E(r,e.length);!function(t,r,e){for(var n=r[0].length,o=t[Math.floor(n/2)],a=[],i=[],s=0,u=void 0;s<n;++s)u=t[s]-o,0===s?(a.push(u),i.push(u*u)):(a.push(a[s-1]+u),i.push(i[s-1]+u*u)),r[0][s]=y(0,s,a,i),e[0][s]=0;for(var h=1;h<r.length;++h)S(h<r.length-1?h:n-1,n-1,h,r,e,a,i)}(e,n,o);for(var a=[],s=o[0].length-1,u=o.length-1;u>=0;u--){var h=o[u][s];a[u]=e.slice(h,s+1),u>0&&(s=h-1)}return a},exports.uniqueCountSorted=q,exports.sumNthPowerDeviations=e,exports.equalIntervalBreaks=function(t,r){if(t.length<2)return t;for(var e=s(t),n=u(t),o=[e],a=(n-e)/r,i=1;i<r;i++)o.push(o[0]+a*i);return o.push(n),o},exports.sampleCovariance=k,exports.sampleCorrelation=function(t,r){return k(t,r)/P(t)/P(r)},exports.sampleVariance=I,exports.sampleStandardDeviation=P,exports.sampleSkewness=function(t){if(t.length<3)throw new Error("sampleSkewness requires at least three data points");for(var e,n=r(t),o=0,a=0,i=0;i<t.length;i++)o+=(e=t[i]-n)*e,a+=e*e*e;var s=Math.sqrt(o/(t.length-1)),u=t.length;return u*a/((u-1)*(u-2)*Math.pow(s,3))},exports.sampleKurtosis=function(t){var e=t.length;if(e<4)throw new Error("sampleKurtosis requires at least four data points");for(var n,o=r(t),a=0,i=0,s=0;s<e;s++)a+=(n=t[s]-o)*n,i+=n*n*n*n;return(e-1)/((e-2)*(e-3))*(e*(e+1)*i/(a*a)-3*(e-1))},exports.permutationsHeap=function(t){for(var r=new Array(t.length),e=[t.slice()],n=0;n<t.length;n++)r[n]=0;for(var o=0;o<t.length;)if(r[o]<o){var a=0;o%2!=0&&(a=r[o]);var i=t[a];t[a]=t[o],t[o]=i,e.push(t.slice()),r[o]++,o=0}else r[o]=0,o++;return e},exports.combinations=function t(r,e){var n,o,a,i,s=[];for(n=0;n<r.length;n++)if(1===e)s.push([r[n]]);else for(a=t(r.slice(n+1,r.length),e-1),o=0;o<a.length;o++)(i=a[o]).unshift(r[n]),s.push(i);return s},exports.combinationsReplacement=function t(r,e){for(var n=[],o=0;o<r.length;o++)if(1===e)n.push([r[o]]);else for(var a=t(r.slice(o,r.length),e-1),i=0;i<a.length;i++)n.push([r[o]].concat(a[i]));return n},exports.addToMean=function(t,r,e){return t+(e-t)/(r+1)},exports.combineMeans=D,exports.combineVariances=function(t,r,e,n,o,a){var i=D(r,e,o,a);return(e*(t+Math.pow(r-i,2))+a*(n+Math.pow(o-i,2)))/(e+a)},exports.geometricMean=function(t){if(0===t.length)throw new Error("geometricMean requires at least one data point");for(var r=1,e=0;e<t.length;e++){if(t[e]<=0)throw new Error("geometricMean requires only positive numbers as input");r*=t[e]}return Math.pow(r,1/t.length)},exports.harmonicMean=function(t){if(0===t.length)throw new Error("harmonicMean requires at least one data point");for(var r=0,e=0;e<t.length;e++){if(t[e]<=0)throw new Error("harmonicMean requires only positive numbers as input");r+=1/t[e]}return t.length/r},exports.average=r,exports.mean=r,exports.median=x,exports.medianSorted=function(t){return h(t,.5)},exports.subtractFromMean=function(t,r,e){return(t*r-e)/(r-1)},exports.rootMeanSquare=C,exports.rms=C,exports.variance=n,exports.tTest=function(t,e){return(r(t)-e)/(o(t)/Math.sqrt(t.length))},exports.tTestTwoSample=function(t,e,n){var o=t.length,a=e.length;if(!o||!a)return null;n||(n=0);var i=r(t),s=r(e),u=I(t),h=I(e);return"number"==typeof i&&"number"==typeof s&&"number"==typeof u&&"number"==typeof h?(i-s-n)/Math.sqrt(((o-1)*u+(a-1)*h)/(o+a-2)*(1/o+1/a)):void 0},exports.BayesianClassifier=T,exports.bayesian=T,exports.PerceptronModel=N,exports.perceptron=N,exports.epsilon=R,exports.factorial=F,exports.gamma=function t(r){if(Number.isInteger(r))return r<=0?NaN:F(r-1);if(--r<0)return Math.PI/(Math.sin(Math.PI*-r)*t(-r));var e=r+.25;return Math.pow(r/Math.E,r)*Math.sqrt(2*Math.PI*(r+1/6))*(1+1/144/Math.pow(e,2)-1/12960/Math.pow(e,3)-257/207360/Math.pow(e,4)-52/2612736/Math.pow(e,5)+5741173/9405849600/Math.pow(e,6)+37529/18811699200/Math.pow(e,7))},exports.gammaln=function(t){if(t<=0)return Infinity;t--;for(var r=A[0],e=1;e<15;e++)r+=A[e]/(t+e);var n=_+.5+t;return z+Math.log(r)-n+(t+.5)*Math.log(n)},exports.bernoulliDistribution=function(t){if(t<0||t>1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-t,t]},exports.binomialDistribution=function(t,r){if(!(r<0||r>1||t<=0||t%1!=0)){var e=0,n=0,o=[],a=1;do{o[e]=a*Math.pow(r,e)*Math.pow(1-r,t-e),n+=o[e],a=a*(t-++e+1)/e}while(n<1-R);return o}},exports.poissonDistribution=function(t){if(!(t<=0)){var r=0,e=0,n=[],o=1;do{n[r]=Math.exp(-t)*Math.pow(t,r)/o,e+=n[r],o*=++r}while(e<1-R);return n}},exports.chiSquaredDistributionTable=V,exports.chiSquaredGoodnessOfFit=function(t,e,n){for(var o=0,a=e(r(t)),i=[],s=[],u=0;u<t.length;u++)void 0===i[t[u]]&&(i[t[u]]=0),i[t[u]]++;for(var h=0;h<i.length;h++)void 0===i[h]&&(i[h]=0);for(var f in a)f in i&&(s[+f]=a[f]*t.length);for(var l=s.length-1;l>=0;l--)s[l]<3&&(s[l-1]+=s[l],s.pop(),i[l-1]+=i[l],i.pop());for(var p=0;p<i.length;p++)o+=Math.pow(i[p]-s[p],2)/s[p];return V[i.length-1-1][n]<o},exports.kernelDensityEstimation=G,exports.kde=G,exports.zScore=function(t,r,e){return(t-r)/e},exports.cumulativeStdNormalProbability=function(t){var r=Math.abs(t),e=Math.min(Math.round(100*r),O.length-1);return t>=0?O[e]:+(1-O[e]).toFixed(4)},exports.standardNormalTable=O,exports.errorFunction=j,exports.erf=j,exports.inverseErrorFunction=J,exports.probit=function(t){return 0===t?t=R:t>=1&&(t=1-R),Math.sqrt(2)*J(2*t-1)},exports.permutationTest=function(t,e,n,o){if(void 0===o&&(o=1e4),void 0===n&&(n="two_side"),"two_side"!==n&&"greater"!==n&&"less"!==n)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'");for(var a=r(t)-r(e),i=new Array(o),s=t.concat(e),u=Math.floor(s.length/2),h=0;h<o;h++){d(s);var f=s.slice(0,u),l=s.slice(u,s.length),p=r(f)-r(l);i[h]=p}var c=0;if("two_side"===n)for(var g=0;g<=o;g++)Math.abs(i[g])>=Math.abs(a)&&(c+=1);else if("greater"===n)for(var v=0;v<=o;v++)i[v]>=a&&(c+=1);else for(var w=0;w<=o;w++)i[w]<=a&&(c+=1);return c/o},exports.bisect=function(t,r,e,n,o){if("function"!=typeof t)throw new TypeError("func must be a function");for(var a=0;a<n;a++){var i=(r+e)/2;if(0===t(i)||Math.abs((e-r)/2)<o)return i;Q(t(i))===Q(t(r))?r=i:e=i}throw new Error("maximum number of iterations exceeded")},exports.quickselect=f,exports.sign=Q,exports.numericSort=i;
//# sourceMappingURL=simple-statistics.js.map

@@ -1,2 +0,2 @@

!function(r,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t(r.ss={})}(this,function(r){function t(r){if(0===r.length)return 0;for(var t,n=r[0],e=0,o=1;o<r.length;o++)t=n+r[o],Math.abs(n)>=Math.abs(r[o])?e+=n-t+r[o]:e+=r[o]-t+n,n=t;return n+e}function n(r){if(0===r.length)throw new Error("mean requires at least one data point");return t(r)/r.length}function e(r,t){var e,o,a=n(r),i=0;if(2===t)for(o=0;o<r.length;o++)i+=(e=r[o]-a)*e;else for(o=0;o<r.length;o++)i+=Math.pow(r[o]-a,t);return i}function o(r){if(0===r.length)throw new Error("variance requires at least one data point");return e(r,2)/r.length}function a(r){if(1===r.length)return 0;var t=o(r);return Math.sqrt(t)}function i(r){if(0===r.length)throw new Error("mode requires at least one data point");if(1===r.length)return r[0];for(var t=r[0],n=NaN,e=0,o=1,a=1;a<r.length+1;a++)r[a]!==t?(o>e&&(e=o,n=t),o=1,t=r[a]):o++;return n}function h(r){return r.slice().sort(function(r,t){return r-t})}function u(r){if(0===r.length)throw new Error("min requires at least one data point");for(var t=r[0],n=1;n<r.length;n++)r[n]<t&&(t=r[n]);return t}function f(r){if(0===r.length)throw new Error("max requires at least one data point");for(var t=r[0],n=1;n<r.length;n++)r[n]>t&&(t=r[n]);return t}function l(r,t){var n=r.length*t;if(0===r.length)throw new Error("quantile requires at least one data point.");if(t<0||t>1)throw new Error("quantiles must be between 0 and 1");return 1===t?r[r.length-1]:0===t?r[0]:n%1!=0?r[Math.ceil(n)-1]:r.length%2==0?(r[n-1]+r[n])/2:r[n]}function s(r,t,n,e){for(n=n||0,e=e||r.length-1;e>n;){if(e-n>600){var o=e-n+1,a=t-n+1,i=Math.log(o),h=.5*Math.exp(2*i/3),u=.5*Math.sqrt(i*h*(o-h)/o);a-o/2<0&&(u*=-1),s(r,t,Math.max(n,Math.floor(t-a*h/o+u)),Math.min(e,Math.floor(t+(o-a)*h/o+u)))}var f=r[t],l=n,g=e;for(c(r,n,t),r[e]>f&&c(r,n,e);l<g;){for(c(r,l,g),l++,g--;r[l]<f;)l++;for(;r[g]>f;)g--}r[n]===f?c(r,n,g):c(r,++g,e),g<=t&&(n=g+1),t<=g&&(e=g-1)}}function c(r,t,n){var e=r[t];r[t]=r[n],r[n]=e}function g(r,t){var n=r.slice();if(Array.isArray(t)){!function(r,t){for(var n=[0],e=0;e<t.length;e++)n.push(M(r.length,t[e]));n.push(r.length-1),n.sort(p);var o=[0,n.length-1];for(;o.length;){var a=Math.ceil(o.pop()),i=Math.floor(o.pop());if(!(a-i<=1)){var h=Math.floor((i+a)/2);v(r,n[h],Math.floor(n[i]),Math.ceil(n[a])),o.push(i,h,h,a)}}}(n,t);for(var e=[],o=0;o<t.length;o++)e[o]=l(n,t[o]);return e}return v(n,M(n.length,t),0,n.length-1),l(n,t)}function v(r,t,n,e){t%1==0?s(r,t,n,e):(s(r,t=Math.floor(t),n,e),s(r,t+1,t+1,e))}function p(r,t){return r-t}function M(r,t){var n=r*t;return 1===t?r-1:0===t?0:n%1!=0?Math.ceil(n)-1:r%2==0?n-.5:n}function w(r,t){if(t<r[0])return 0;if(t>r[r.length-1])return 1;var n=function(r,t){var n=0,e=0,o=r.length;for(;e<o;)t<=r[n=e+o>>>1]?o=n:e=-~n;return e}(r,t);if(r[n]!==t)return n/r.length;n++;var e=function(r,t){var n=0,e=0,o=r.length;for(;e<o;)t>=r[n=e+o>>>1]?e=-~n:o=n;return e}(r,t);if(e===n)return n/r.length;var o=e-n+1;return o*(e+n)/2/o/r.length}function d(r){var t=g(r,.75),n=g(r,.25);if("number"==typeof t&&"number"==typeof n)return t-n}function q(r){return+g(r,.5)}function m(r){for(var t=q(r),n=[],e=0;e<r.length;e++)n.push(Math.abs(r[e]-t));return q(n)}function b(r,t){t=t||Math.random;for(var n,e,o=r.length;o>0;)e=Math.floor(t()*o--),n=r[o],r[o]=r[e],r[e]=n;return r}function y(r,t){return b(r.slice().slice(),t)}function E(r){for(var t,n=0,e=0;e<r.length;e++)0!==e&&r[e]===t||(t=r[e],n++);return n}function I(r,t){for(var n=[],e=0;e<r;e++){for(var o=[],a=0;a<t;a++)o.push(0);n.push(o)}return n}function P(r,t,n,e){var o;if(r>0){var a=(n[t]-n[r-1])/(t-r+1);o=e[t]-e[r-1]-(t-r+1)*a*a}else o=e[t]-n[t]*n[t]/(t+1);return o<0?0:o}function C(r,t,n,e,o,a,i){if(!(r>t)){var h=Math.floor((r+t)/2);e[n][h]=e[n-1][h-1],o[n][h]=h;var u=n;r>n&&(u=Math.max(u,o[n][r-1]||0)),u=Math.max(u,o[n-1][h]||0);var f,l,s,c=h-1;t<e.length-1&&(c=Math.min(c,o[n][t+1]||0));for(var g=c;g>=u&&!((f=P(g,h,a,i))+e[n-1][u-1]>=e[n][h]);--g)(l=P(u,h,a,i)+e[n-1][u-1])<e[n][h]&&(e[n][h]=l,o[n][h]=u),u++,(s=f+e[n-1][g-1])<e[n][h]&&(e[n][h]=s,o[n][h]=g);C(r,h-1,n,e,o,a,i),C(h+1,t,n,e,o,a,i)}}function N(r,t){if(r.length!==t.length)throw new Error("sampleCovariance requires samples with equal lengths");if(r.length<2)throw new Error("sampleCovariance requires at least two data points in each sample");for(var e=n(r),o=n(t),a=0,i=0;i<r.length;i++)a+=(r[i]-e)*(t[i]-o);return a/(r.length-1)}function R(r){if(r.length<2)throw new Error("sampleVariance requires at least two data points");return e(r,2)/(r.length-1)}function D(r){var t=R(r);return Math.sqrt(t)}function A(r,t,n,e){return(r*t+n*e)/(t+e)}function S(r){if(0===r.length)throw new Error("rootMeanSquare requires at least one data point");for(var t=0,n=0;n<r.length;n++)t+=Math.pow(r[n],2);return Math.sqrt(t/r.length)}var T=function(){this.totalCount=0,this.data={}};T.prototype.train=function(r,t){for(var n in this.data[t]||(this.data[t]={}),r){var e=r[n];void 0===this.data[t][n]&&(this.data[t][n]={}),void 0===this.data[t][n][e]&&(this.data[t][n][e]=0),this.data[t][n][e]++}this.totalCount++},T.prototype.score=function(r){var t,n={};for(var e in r){var o=r[e];for(t in this.data)n[t]={},n[t][e+"_"+o]=this.data[t][e]?(this.data[t][e][o]||0)/this.totalCount:0}var a={};for(t in n)for(var i in a[t]=0,n[t])a[t]+=n[t][i];return a};var _=function(){this.weights=[],this.bias=0};_.prototype.predict=function(r){if(r.length!==this.weights.length)return null;for(var t=0,n=0;n<this.weights.length;n++)t+=this.weights[n]*r[n];return(t+=this.bias)>0?1:0},_.prototype.train=function(r,t){if(0!==t&&1!==t)return null;r.length!==this.weights.length&&(this.weights=r,this.bias=1);var n=this.predict(r);if("number"==typeof n&&n!==t){for(var e=t-n,o=0;o<this.weights.length;o++)this.weights[o]+=e*r[o];this.bias+=e}return this};var x=1e-4;function z(r){if(r<0)throw new Error("factorial requires a non-negative value");if(Math.floor(r)!==r)throw new Error("factorial requires an integer input");for(var t=1,n=2;n<=r;n++)t*=n;return t}var B=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],K=607/128,U=Math.log(Math.sqrt(2*Math.PI));var G={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}};var H=Math.sqrt(2*Math.PI),W={gaussian:function(r){return Math.exp(-.5*r*r)/H}},J={nrd:function(r){var t=D(r),n=d(r);return"number"==typeof n&&(t=Math.min(t,n/1.34)),1.06*t*Math.pow(r.length,-.2)}};function Q(r,t,n){var e,o;if(void 0===t)e=W.gaussian;else if("string"==typeof t){if(!W[t])throw new Error('Unknown kernel "'+t+'"');e=W[t]}else e=t;if(void 0===n)o=J.nrd(r);else if("string"==typeof n){if(!J[n])throw new Error('Unknown bandwidth method "'+n+'"');o=J[n](r)}else o=n;return function(t){var n=0,a=0;for(n=0;n<r.length;n++)a+=e((t-r[n])/o);return a/o/r.length}}var Y=Math.sqrt(2*Math.PI);function Z(r){for(var t=r,n=r,e=1;e<15;e++)t+=n*=r*r/(2*e+1);return Math.round(1e4*(.5+t/Y*Math.exp(-r*r/2)))/1e4}for(var L=[],O=0;O<=3.09;O+=.01)L.push(Z(O));function V(r){var t=1/(1+.5*Math.abs(r)),n=t*Math.exp(-Math.pow(r,2)-1.26551223+1.00002368*t+.37409196*Math.pow(t,2)+.09678418*Math.pow(t,3)-.18628806*Math.pow(t,4)+.27886807*Math.pow(t,5)-1.13520398*Math.pow(t,6)+1.48851587*Math.pow(t,7)-.82215223*Math.pow(t,8)+.17087277*Math.pow(t,9));return r>=0?1-n:n-1}function X(r){var t=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),n=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*t)+Math.log(1-r*r)/2,2)-Math.log(1-r*r)/t)-(2/(Math.PI*t)+Math.log(1-r*r)/2));return r>=0?n:-n}function k(r){if("number"==typeof r)return r<0?-1:0===r?0:1;throw new TypeError("not a number")}r.linearRegression=function(r){var t,n,e=r.length;if(1===e)t=0,n=r[0][1];else{for(var o,a,i,h=0,u=0,f=0,l=0,s=0;s<e;s++)h+=a=(o=r[s])[0],u+=i=o[1],f+=a*a,l+=a*i;n=u/e-(t=(e*l-h*u)/(e*f-h*h))*h/e}return{m:t,b:n}},r.linearRegressionLine=function(r){return function(t){return r.b+r.m*t}},r.standardDeviation=a,r.rSquared=function(r,t){if(r.length<2)return 1;for(var n=0,e=0;e<r.length;e++)n+=r[e][1];for(var o=n/r.length,a=0,i=0;i<r.length;i++)a+=Math.pow(o-r[i][1],2);for(var h=0,u=0;u<r.length;u++)h+=Math.pow(r[u][1]-t(r[u][0]),2);return 1-h/a},r.mode=function(r){return i(h(r))},r.modeFast=function(r){for(var t,n=new Map,e=0,o=0;o<r.length;o++){var a=n.get(r[o]);void 0===a?a=1:a++,a>e&&(t=r[o],e=a),n.set(r[o],a)}if(0===e)throw new Error("mode requires at last one data point");return t},r.modeSorted=i,r.min=u,r.max=f,r.extent=function(r){if(0===r.length)throw new Error("extent requires at least one data point");for(var t=r[0],n=r[0],e=1;e<r.length;e++)r[e]>n&&(n=r[e]),r[e]<t&&(t=r[e]);return[t,n]},r.minSorted=function(r){return r[0]},r.maxSorted=function(r){return r[r.length-1]},r.extentSorted=function(r){return[r[0],r[r.length-1]]},r.sum=t,r.sumSimple=function(r){for(var t=0,n=0;n<r.length;n++)t+=r[n];return t},r.product=function(r){for(var t=1,n=0;n<r.length;n++)t*=r[n];return t},r.quantile=g,r.quantileSorted=l,r.quantileRank=function(r,t){return w(h(r),t)},r.quantileRankSorted=w,r.interquartileRange=d,r.iqr=d,r.medianAbsoluteDeviation=m,r.mad=m,r.chunk=function(r,t){var n=[];if(t<1)throw new Error("chunk size must be a positive number");if(Math.floor(t)!==t)throw new Error("chunk size must be an integer");for(var e=0;e<r.length;e+=t)n.push(r.slice(e,e+t));return n},r.sampleWithReplacement=function(r,t,n){if(0===r.length)return[];n=n||Math.random;for(var e=r.length,o=[],a=0;a<t;a++){var i=Math.floor(n()*e);o.push(r[i])}return o},r.shuffle=y,r.shuffleInPlace=b,r.sample=function(r,t,n){return y(r,n).slice(0,t)},r.ckmeans=function(r,t){if(t>r.length)throw new Error("cannot generate more classes than there are data values");var n=h(r);if(1===E(n))return[n];var e=I(t,n.length),o=I(t,n.length);!function(r,t,n){for(var e=t[0].length,o=r[Math.floor(e/2)],a=[],i=[],h=0,u=void 0;h<e;++h)u=r[h]-o,0===h?(a.push(u),i.push(u*u)):(a.push(a[h-1]+u),i.push(i[h-1]+u*u)),t[0][h]=P(0,h,a,i),n[0][h]=0;for(var f=1;f<t.length;++f)C(f<t.length-1?f:e-1,e-1,f,t,n,a,i)}(n,e,o);for(var a=[],i=o[0].length-1,u=o.length-1;u>=0;u--){var f=o[u][i];a[u]=n.slice(f,i+1),u>0&&(i=f-1)}return a},r.uniqueCountSorted=E,r.sumNthPowerDeviations=e,r.equalIntervalBreaks=function(r,t){if(r.length<2)return r;for(var n=u(r),e=f(r),o=[n],a=(e-n)/t,i=1;i<t;i++)o.push(o[0]+a*i);return o.push(e),o},r.sampleCovariance=N,r.sampleCorrelation=function(r,t){return N(r,t)/D(r)/D(t)},r.sampleVariance=R,r.sampleStandardDeviation=D,r.sampleSkewness=function(r){if(r.length<3)throw new Error("sampleSkewness requires at least three data points");for(var t,e=n(r),o=0,a=0,i=0;i<r.length;i++)o+=(t=r[i]-e)*t,a+=t*t*t;var h=Math.sqrt(o/(r.length-1)),u=r.length;return u*a/((u-1)*(u-2)*Math.pow(h,3))},r.sampleKurtosis=function(r){var t=r.length;if(t<4)throw new Error("sampleKurtosis requires at least four data points");for(var e,o=n(r),a=0,i=0,h=0;h<t;h++)a+=(e=r[h]-o)*e,i+=e*e*e*e;return(t-1)/((t-2)*(t-3))*(t*(t+1)*i/(a*a)-3*(t-1))},r.permutationsHeap=function(r){for(var t=new Array(r.length),n=[r.slice()],e=0;e<r.length;e++)t[e]=0;for(var o=0;o<r.length;)if(t[o]<o){var a=0;o%2!=0&&(a=t[o]);var i=r[a];r[a]=r[o],r[o]=i,n.push(r.slice()),t[o]++,o=0}else t[o]=0,o++;return n},r.combinations=function r(t,n){var e,o,a,i,h=[];for(e=0;e<t.length;e++)if(1===n)h.push([t[e]]);else for(a=r(t.slice(e+1,t.length),n-1),o=0;o<a.length;o++)(i=a[o]).unshift(t[e]),h.push(i);return h},r.combinationsReplacement=function r(t,n){for(var e=[],o=0;o<t.length;o++)if(1===n)e.push([t[o]]);else for(var a=r(t.slice(o,t.length),n-1),i=0;i<a.length;i++)e.push([t[o]].concat(a[i]));return e},r.addToMean=function(r,t,n){return r+(n-r)/(t+1)},r.combineMeans=A,r.combineVariances=function(r,t,n,e,o,a){var i=A(t,n,o,a);return(n*(r+Math.pow(t-i,2))+a*(e+Math.pow(o-i,2)))/(n+a)},r.geometricMean=function(r){if(0===r.length)throw new Error("geometricMean requires at least one data point");for(var t=1,n=0;n<r.length;n++){if(r[n]<=0)throw new Error("geometricMean requires only positive numbers as input");t*=r[n]}return Math.pow(t,1/r.length)},r.harmonicMean=function(r){if(0===r.length)throw new Error("harmonicMean requires at least one data point");for(var t=0,n=0;n<r.length;n++){if(r[n]<=0)throw new Error("harmonicMean requires only positive numbers as input");t+=1/r[n]}return r.length/t},r.average=n,r.mean=n,r.median=q,r.medianSorted=function(r){return l(r,.5)},r.subtractFromMean=function(r,t,n){return(r*t-n)/(t-1)},r.rootMeanSquare=S,r.rms=S,r.variance=o,r.tTest=function(r,t){return(n(r)-t)/(a(r)/Math.sqrt(r.length))},r.tTestTwoSample=function(r,t,e){var o=r.length,a=t.length;if(!o||!a)return null;e||(e=0);var i=n(r),h=n(t),u=R(r),f=R(t);return"number"==typeof i&&"number"==typeof h&&"number"==typeof u&&"number"==typeof f?(i-h-e)/Math.sqrt(((o-1)*u+(a-1)*f)/(o+a-2)*(1/o+1/a)):void 0},r.BayesianClassifier=T,r.bayesian=T,r.PerceptronModel=_,r.perceptron=_,r.epsilon=x,r.factorial=z,r.gamma=function r(t){if(Number.isInteger(t))return t<=0?NaN:z(t-1);if(--t<0)return Math.PI/(Math.sin(Math.PI*-t)*r(-t));var n=t+.25;return Math.pow(t/Math.E,t)*Math.sqrt(2*Math.PI*(t+1/6))*(1+1/144/Math.pow(n,2)-1/12960/Math.pow(n,3)-257/207360/Math.pow(n,4)-52/2612736/Math.pow(n,5)+5741173/9405849600/Math.pow(n,6)+37529/18811699200/Math.pow(n,7))},r.gammaln=function(r){if(r<=0)return Infinity;r--;for(var t=B[0],n=1;n<15;n++)t+=B[n]/(r+n);var e=K+.5+r;return U+Math.log(t)-e+(r+.5)*Math.log(e)},r.bernoulliDistribution=function(r){if(r<0||r>1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-r,r]},r.binomialDistribution=function(r,t){if(!(t<0||t>1||r<=0||r%1!=0)){var n=0,e=0,o=[],a=1;do{o[n]=a*Math.pow(t,n)*Math.pow(1-t,r-n),e+=o[n],a=a*(r-++n+1)/n}while(e<1-x);return o}},r.poissonDistribution=function(r){if(!(r<=0)){var t=0,n=0,e=[],o=1;do{e[t]=Math.exp(-r)*Math.pow(r,t)/o,n+=e[t],o*=++t}while(n<1-x);return e}},r.chiSquaredDistributionTable=G,r.chiSquaredGoodnessOfFit=function(r,t,e){for(var o=0,a=t(n(r)),i=[],h=[],u=0;u<r.length;u++)void 0===i[r[u]]&&(i[r[u]]=0),i[r[u]]++;for(var f=0;f<i.length;f++)void 0===i[f]&&(i[f]=0);for(var l in a)l in i&&(h[+l]=a[l]*r.length);for(var s=h.length-1;s>=0;s--)h[s]<3&&(h[s-1]+=h[s],h.pop(),i[s-1]+=i[s],i.pop());for(var c=0;c<i.length;c++)o+=Math.pow(i[c]-h[c],2)/h[c];return G[i.length-1-1][e]<o},r.kernelDensityEstimation=Q,r.kde=Q,r.zScore=function(r,t,n){return(r-t)/n},r.cumulativeStdNormalProbability=function(r){var t=Math.abs(r),n=Math.min(Math.round(100*t),L.length-1);return r>=0?L[n]:+(1-L[n]).toFixed(4)},r.standardNormalTable=L,r.errorFunction=V,r.erf=V,r.inverseErrorFunction=X,r.probit=function(r){return 0===r?r=x:r>=1&&(r=1-x),Math.sqrt(2)*X(2*r-1)},r.permutationTest=function(r,t,e,o){if(void 0===o&&(o=1e4),void 0===e&&(e="two_side"),"two_side"!==e&&"greater"!==e&&"less"!==e)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'");for(var a=n(r)-n(t),i=new Array(o),h=r.concat(t),u=Math.floor(h.length/2),f=0;f<o;f++){b(h);var l=h.slice(0,u),s=h.slice(u,h.length),c=n(l)-n(s);i[f]=c}var g=0;if("two_side"===e)for(var v=0;v<=o;v++)Math.abs(i[v])>=Math.abs(a)&&(g+=1);else if("greater"===e)for(var p=0;p<=o;p++)i[p]>=a&&(g+=1);else for(var M=0;M<=o;M++)i[M]<=a&&(g+=1);return g/o},r.bisect=function(r,t,n,e,o){if("function"!=typeof r)throw new TypeError("func must be a function");for(var a=0;a<e;a++){var i=(t+n)/2;if(0===r(i)||Math.abs((n-t)/2)<o)return i;k(r(i))===k(r(t))?t=i:n=i}throw new Error("maximum number of iterations exceeded")},r.quickselect=s,r.sign=k,r.numericSort=h});
!function(t,r){"object"==typeof exports&&"undefined"!=typeof module?r(exports):"function"==typeof define&&define.amd?define(["exports"],r):r(t.ss={})}(this,function(t){function r(t){if(0===t.length)return 0;for(var r,n=t[0],e=0,a=1;a<t.length;a++)r=n+t[a],Math.abs(n)>=Math.abs(t[a])?e+=n-r+t[a]:e+=t[a]-r+n,n=r;return n+e}function n(t){if(0===t.length)throw new Error("mean requires at least one data point");return r(t)/t.length}function e(t,r){var e,a,o=n(t),i=0;if(2===r)for(a=0;a<t.length;a++)i+=(e=t[a]-o)*e;else for(a=0;a<t.length;a++)i+=Math.pow(t[a]-o,r);return i}function a(t){if(0===t.length)throw new Error("variance requires at least one data point");return e(t,2)/t.length}function o(t){if(1===t.length)return 0;var r=a(t);return Math.sqrt(r)}function i(t){if(0===t.length)throw new Error("mode requires at least one data point");if(1===t.length)return t[0];for(var r=t[0],n=NaN,e=0,a=1,o=1;o<t.length+1;o++)t[o]!==r?(a>e&&(e=a,n=r),a=1,r=t[o]):a++;return n}function u(t){return t.slice().sort(function(t,r){return t-r})}function h(t){if(0===t.length)throw new Error("min requires at least one data point");for(var r=t[0],n=1;n<t.length;n++)t[n]<r&&(r=t[n]);return r}function f(t){if(0===t.length)throw new Error("max requires at least one data point");for(var r=t[0],n=1;n<t.length;n++)t[n]>r&&(r=t[n]);return r}function s(t,r){var n=t.length*r;if(0===t.length)throw new Error("quantile requires at least one data point.");if(r<0||r>1)throw new Error("quantiles must be between 0 and 1");return 1===r?t[t.length-1]:0===r?t[0]:n%1!=0?t[Math.ceil(n)-1]:t.length%2==0?(t[n-1]+t[n])/2:t[n]}function l(t,r,n,e){for(n=n||0,e=e||t.length-1;e>n;){if(e-n>600){var a=e-n+1,o=r-n+1,i=Math.log(a),u=.5*Math.exp(2*i/3),h=.5*Math.sqrt(i*u*(a-u)/a);o-a/2<0&&(h*=-1),l(t,r,Math.max(n,Math.floor(r-o*u/a+h)),Math.min(e,Math.floor(r+(a-o)*u/a+h)))}var f=t[r],s=n,g=e;for(c(t,n,r),t[e]>f&&c(t,n,e);s<g;){for(c(t,s,g),s++,g--;t[s]<f;)s++;for(;t[g]>f;)g--}t[n]===f?c(t,n,g):c(t,++g,e),g<=r&&(n=g+1),r<=g&&(e=g-1)}}function c(t,r,n){var e=t[r];t[r]=t[n],t[n]=e}function g(t,r){var n=t.slice();if(Array.isArray(r)){!function(t,r){for(var n=[0],e=0;e<r.length;e++)n.push(w(t.length,r[e]));n.push(t.length-1),n.sort(p);var a=[0,n.length-1];for(;a.length;){var o=Math.ceil(a.pop()),i=Math.floor(a.pop());if(!(o-i<=1)){var u=Math.floor((i+o)/2);v(t,n[u],Math.floor(n[i]),Math.ceil(n[o])),a.push(i,u,u,o)}}}(n,r);for(var e=[],a=0;a<r.length;a++)e[a]=s(n,r[a]);return e}return v(n,w(n.length,r),0,n.length-1),s(n,r)}function v(t,r,n,e){r%1==0?l(t,r,n,e):(l(t,r=Math.floor(r),n,e),l(t,r+1,r+1,e))}function p(t,r){return t-r}function w(t,r){var n=t*r;return 1===r?t-1:0===r?0:n%1!=0?Math.ceil(n)-1:t%2==0?n-.5:n}function M(t,r){if(r<t[0])return 0;if(r>t[t.length-1])return 1;var n=function(t,r){var n=0,e=0,a=t.length;for(;e<a;)r<=t[n=e+a>>>1]?a=n:e=-~n;return e}(t,r);if(t[n]!==r)return n/t.length;n++;var e=function(t,r){var n=0,e=0,a=t.length;for(;e<a;)r>=t[n=e+a>>>1]?e=-~n:a=n;return e}(t,r);if(e===n)return n/t.length;var a=e-n+1;return a*(e+n)/2/a/t.length}function m(t){var r=g(t,.75),n=g(t,.25);if("number"==typeof r&&"number"==typeof n)return r-n}function d(t){return+g(t,.5)}function b(t){for(var r=d(t),n=[],e=0;e<t.length;e++)n.push(Math.abs(t[e]-r));return d(n)}function q(t,r){r=r||Math.random;for(var n,e,a=t.length;a>0;)e=Math.floor(r()*a--),n=t[a],t[a]=t[e],t[e]=n;return t}function E(t,r){return q(t.slice().slice(),r)}function y(t){for(var r,n=0,e=0;e<t.length;e++)0!==e&&t[e]===r||(r=t[e],n++);return n}function S(t,r){for(var n=[],e=0;e<t;e++){for(var a=[],o=0;o<r;o++)a.push(0);n.push(a)}return n}function x(t,r,n,e){var a;if(t>0){var o=(n[r]-n[t-1])/(r-t+1);a=e[r]-e[t-1]-(r-t+1)*o*o}else a=e[r]-n[r]*n[r]/(r+1);return a<0?0:a}function k(t,r,n,e,a,o,i){if(!(t>r)){var u=Math.floor((t+r)/2);e[n][u]=e[n-1][u-1],a[n][u]=u;var h=n;t>n&&(h=Math.max(h,a[n][t-1]||0)),h=Math.max(h,a[n-1][u]||0);var f,s,l,c=u-1;r<e.length-1&&(c=Math.min(c,a[n][r+1]||0));for(var g=c;g>=h&&!((f=x(g,u,o,i))+e[n-1][h-1]>=e[n][u]);--g)(s=x(h,u,o,i)+e[n-1][h-1])<e[n][u]&&(e[n][u]=s,a[n][u]=h),h++,(l=f+e[n-1][g-1])<e[n][u]&&(e[n][u]=l,a[n][u]=g);k(t,u-1,n,e,a,o,i),k(u+1,r,n,e,a,o,i)}}function I(t,r){if(t.length!==r.length)throw new Error("sampleCovariance requires samples with equal lengths");if(t.length<2)throw new Error("sampleCovariance requires at least two data points in each sample");for(var e=n(t),a=n(r),o=0,i=0;i<t.length;i++)o+=(t[i]-e)*(r[i]-a);return o/(t.length-1)}function P(t){if(t.length<2)throw new Error("sampleVariance requires at least two data points");return e(t,2)/(t.length-1)}function D(t){var r=P(t);return Math.sqrt(r)}function C(t,r,n,e){return(t*r+n*e)/(r+e)}function T(t){if(0===t.length)throw new Error("rootMeanSquare requires at least one data point");for(var r=0,n=0;n<t.length;n++)r+=Math.pow(t[n],2);return Math.sqrt(r/t.length)}var N=function(){this.totalCount=0,this.data={}};N.prototype.train=function(t,r){for(var n in this.data[r]||(this.data[r]={}),t){var e=t[n];void 0===this.data[r][n]&&(this.data[r][n]={}),void 0===this.data[r][n][e]&&(this.data[r][n][e]=0),this.data[r][n][e]++}this.totalCount++},N.prototype.score=function(t){var r,n={};for(var e in t){var a=t[e];for(r in this.data)n[r]={},n[r][e+"_"+a]=this.data[r][e]?(this.data[r][e][a]||0)/this.totalCount:0}var o={};for(r in n)for(var i in o[r]=0,n[r])o[r]+=n[r][i];return o};var R=function(){this.weights=[],this.bias=0};R.prototype.predict=function(t){if(t.length!==this.weights.length)return null;for(var r=0,n=0;n<this.weights.length;n++)r+=this.weights[n]*t[n];return(r+=this.bias)>0?1:0},R.prototype.train=function(t,r){if(0!==r&&1!==r)return null;t.length!==this.weights.length&&(this.weights=t,this.bias=1);var n=this.predict(t);if("number"==typeof n&&n!==r){for(var e=r-n,a=0;a<this.weights.length;a++)this.weights[a]+=e*t[a];this.bias+=e}return this};var F=1e-4;function A(t){if(t<0)throw new Error("factorial requires a non-negative value");if(Math.floor(t)!==t)throw new Error("factorial requires an integer input");for(var r=1,n=2;n<=t;n++)r*=n;return r}var _=[.9999999999999971,57.15623566586292,-59.59796035547549,14.136097974741746,-.4919138160976202,3399464998481189e-20,4652362892704858e-20,-9837447530487956e-20,.0001580887032249125,-.00021026444172410488,.00021743961811521265,-.0001643181065367639,8441822398385275e-20,-26190838401581408e-21,36899182659531625e-22],z=607/128,V=Math.log(Math.sqrt(2*Math.PI));var B={1:{.995:0,.99:0,.975:0,.95:0,.9:.02,.5:.45,.1:2.71,.05:3.84,.025:5.02,.01:6.63,.005:7.88},2:{.995:.01,.99:.02,.975:.05,.95:.1,.9:.21,.5:1.39,.1:4.61,.05:5.99,.025:7.38,.01:9.21,.005:10.6},3:{.995:.07,.99:.11,.975:.22,.95:.35,.9:.58,.5:2.37,.1:6.25,.05:7.81,.025:9.35,.01:11.34,.005:12.84},4:{.995:.21,.99:.3,.975:.48,.95:.71,.9:1.06,.5:3.36,.1:7.78,.05:9.49,.025:11.14,.01:13.28,.005:14.86},5:{.995:.41,.99:.55,.975:.83,.95:1.15,.9:1.61,.5:4.35,.1:9.24,.05:11.07,.025:12.83,.01:15.09,.005:16.75},6:{.995:.68,.99:.87,.975:1.24,.95:1.64,.9:2.2,.5:5.35,.1:10.65,.05:12.59,.025:14.45,.01:16.81,.005:18.55},7:{.995:.99,.99:1.25,.975:1.69,.95:2.17,.9:2.83,.5:6.35,.1:12.02,.05:14.07,.025:16.01,.01:18.48,.005:20.28},8:{.995:1.34,.99:1.65,.975:2.18,.95:2.73,.9:3.49,.5:7.34,.1:13.36,.05:15.51,.025:17.53,.01:20.09,.005:21.96},9:{.995:1.73,.99:2.09,.975:2.7,.95:3.33,.9:4.17,.5:8.34,.1:14.68,.05:16.92,.025:19.02,.01:21.67,.005:23.59},10:{.995:2.16,.99:2.56,.975:3.25,.95:3.94,.9:4.87,.5:9.34,.1:15.99,.05:18.31,.025:20.48,.01:23.21,.005:25.19},11:{.995:2.6,.99:3.05,.975:3.82,.95:4.57,.9:5.58,.5:10.34,.1:17.28,.05:19.68,.025:21.92,.01:24.72,.005:26.76},12:{.995:3.07,.99:3.57,.975:4.4,.95:5.23,.9:6.3,.5:11.34,.1:18.55,.05:21.03,.025:23.34,.01:26.22,.005:28.3},13:{.995:3.57,.99:4.11,.975:5.01,.95:5.89,.9:7.04,.5:12.34,.1:19.81,.05:22.36,.025:24.74,.01:27.69,.005:29.82},14:{.995:4.07,.99:4.66,.975:5.63,.95:6.57,.9:7.79,.5:13.34,.1:21.06,.05:23.68,.025:26.12,.01:29.14,.005:31.32},15:{.995:4.6,.99:5.23,.975:6.27,.95:7.26,.9:8.55,.5:14.34,.1:22.31,.05:25,.025:27.49,.01:30.58,.005:32.8},16:{.995:5.14,.99:5.81,.975:6.91,.95:7.96,.9:9.31,.5:15.34,.1:23.54,.05:26.3,.025:28.85,.01:32,.005:34.27},17:{.995:5.7,.99:6.41,.975:7.56,.95:8.67,.9:10.09,.5:16.34,.1:24.77,.05:27.59,.025:30.19,.01:33.41,.005:35.72},18:{.995:6.26,.99:7.01,.975:8.23,.95:9.39,.9:10.87,.5:17.34,.1:25.99,.05:28.87,.025:31.53,.01:34.81,.005:37.16},19:{.995:6.84,.99:7.63,.975:8.91,.95:10.12,.9:11.65,.5:18.34,.1:27.2,.05:30.14,.025:32.85,.01:36.19,.005:38.58},20:{.995:7.43,.99:8.26,.975:9.59,.95:10.85,.9:12.44,.5:19.34,.1:28.41,.05:31.41,.025:34.17,.01:37.57,.005:40},21:{.995:8.03,.99:8.9,.975:10.28,.95:11.59,.9:13.24,.5:20.34,.1:29.62,.05:32.67,.025:35.48,.01:38.93,.005:41.4},22:{.995:8.64,.99:9.54,.975:10.98,.95:12.34,.9:14.04,.5:21.34,.1:30.81,.05:33.92,.025:36.78,.01:40.29,.005:42.8},23:{.995:9.26,.99:10.2,.975:11.69,.95:13.09,.9:14.85,.5:22.34,.1:32.01,.05:35.17,.025:38.08,.01:41.64,.005:44.18},24:{.995:9.89,.99:10.86,.975:12.4,.95:13.85,.9:15.66,.5:23.34,.1:33.2,.05:36.42,.025:39.36,.01:42.98,.005:45.56},25:{.995:10.52,.99:11.52,.975:13.12,.95:14.61,.9:16.47,.5:24.34,.1:34.28,.05:37.65,.025:40.65,.01:44.31,.005:46.93},26:{.995:11.16,.99:12.2,.975:13.84,.95:15.38,.9:17.29,.5:25.34,.1:35.56,.05:38.89,.025:41.92,.01:45.64,.005:48.29},27:{.995:11.81,.99:12.88,.975:14.57,.95:16.15,.9:18.11,.5:26.34,.1:36.74,.05:40.11,.025:43.19,.01:46.96,.005:49.65},28:{.995:12.46,.99:13.57,.975:15.31,.95:16.93,.9:18.94,.5:27.34,.1:37.92,.05:41.34,.025:44.46,.01:48.28,.005:50.99},29:{.995:13.12,.99:14.26,.975:16.05,.95:17.71,.9:19.77,.5:28.34,.1:39.09,.05:42.56,.025:45.72,.01:49.59,.005:52.34},30:{.995:13.79,.99:14.95,.975:16.79,.95:18.49,.9:20.6,.5:29.34,.1:40.26,.05:43.77,.025:46.98,.01:50.89,.005:53.67},40:{.995:20.71,.99:22.16,.975:24.43,.95:26.51,.9:29.05,.5:39.34,.1:51.81,.05:55.76,.025:59.34,.01:63.69,.005:66.77},50:{.995:27.99,.99:29.71,.975:32.36,.95:34.76,.9:37.69,.5:49.33,.1:63.17,.05:67.5,.025:71.42,.01:76.15,.005:79.49},60:{.995:35.53,.99:37.48,.975:40.48,.95:43.19,.9:46.46,.5:59.33,.1:74.4,.05:79.08,.025:83.3,.01:88.38,.005:91.95},70:{.995:43.28,.99:45.44,.975:48.76,.95:51.74,.9:55.33,.5:69.33,.1:85.53,.05:90.53,.025:95.02,.01:100.42,.005:104.22},80:{.995:51.17,.99:53.54,.975:57.15,.95:60.39,.9:64.28,.5:79.33,.1:96.58,.05:101.88,.025:106.63,.01:112.33,.005:116.32},90:{.995:59.2,.99:61.75,.975:65.65,.95:69.13,.9:73.29,.5:89.33,.1:107.57,.05:113.14,.025:118.14,.01:124.12,.005:128.3},100:{.995:67.33,.99:70.06,.975:74.22,.95:77.93,.9:82.36,.5:99.33,.1:118.5,.05:124.34,.025:129.56,.01:135.81,.005:140.17}};var K=Math.sqrt(2*Math.PI),U={gaussian:function(t){return Math.exp(-.5*t*t)/K}},j={nrd:function(t){var r=D(t),n=m(t);return"number"==typeof n&&(r=Math.min(r,n/1.34)),1.06*r*Math.pow(t.length,-.2)}};function G(t,r,n){var e,a;if(void 0===r)e=U.gaussian;else if("string"==typeof r){if(!U[r])throw new Error('Unknown kernel "'+r+'"');e=U[r]}else e=r;if(void 0===n)a=j.nrd(t);else if("string"==typeof n){if(!j[n])throw new Error('Unknown bandwidth method "'+n+'"');a=j[n](t)}else a=n;return function(r){var n=0,o=0;for(n=0;n<t.length;n++)o+=e((r-t[n])/a);return o/a/t.length}}var H=Math.sqrt(2*Math.PI);function L(t){for(var r=t,n=t,e=1;e<15;e++)r+=n*=t*t/(2*e+1);return Math.round(1e4*(.5+r/H*Math.exp(-t*t/2)))/1e4}for(var O=[],W=0;W<=3.09;W+=.01)O.push(L(W));function J(t){var r=1/(1+.5*Math.abs(t)),n=r*Math.exp(-t*t+((((((((.17087277*r-.82215223)*r+1.48851587)*r-1.13520398)*r+.27886807)*r-.18628806)*r+.09678418)*r+.37409196)*r+1.00002368)*r-1.26551223);return t>=0?1-n:n-1}function Q(t){var r=8*(Math.PI-3)/(3*Math.PI*(4-Math.PI)),n=Math.sqrt(Math.sqrt(Math.pow(2/(Math.PI*r)+Math.log(1-t*t)/2,2)-Math.log(1-t*t)/r)-(2/(Math.PI*r)+Math.log(1-t*t)/2));return t>=0?n:-n}function X(t){if("number"==typeof t)return t<0?-1:0===t?0:1;throw new TypeError("not a number")}t.linearRegression=function(t){var r,n,e=t.length;if(1===e)r=0,n=t[0][1];else{for(var a,o,i,u=0,h=0,f=0,s=0,l=0;l<e;l++)u+=o=(a=t[l])[0],h+=i=a[1],f+=o*o,s+=o*i;n=h/e-(r=(e*s-u*h)/(e*f-u*u))*u/e}return{m:r,b:n}},t.linearRegressionLine=function(t){return function(r){return t.b+t.m*r}},t.standardDeviation=o,t.rSquared=function(t,r){if(t.length<2)return 1;for(var n=0,e=0;e<t.length;e++)n+=t[e][1];for(var a=n/t.length,o=0,i=0;i<t.length;i++)o+=Math.pow(a-t[i][1],2);for(var u=0,h=0;h<t.length;h++)u+=Math.pow(t[h][1]-r(t[h][0]),2);return 1-u/o},t.mode=function(t){return i(u(t))},t.modeFast=function(t){for(var r,n=new Map,e=0,a=0;a<t.length;a++){var o=n.get(t[a]);void 0===o?o=1:o++,o>e&&(r=t[a],e=o),n.set(t[a],o)}if(0===e)throw new Error("mode requires at last one data point");return r},t.modeSorted=i,t.min=h,t.max=f,t.extent=function(t){if(0===t.length)throw new Error("extent requires at least one data point");for(var r=t[0],n=t[0],e=1;e<t.length;e++)t[e]>n&&(n=t[e]),t[e]<r&&(r=t[e]);return[r,n]},t.minSorted=function(t){return t[0]},t.maxSorted=function(t){return t[t.length-1]},t.extentSorted=function(t){return[t[0],t[t.length-1]]},t.sum=r,t.sumSimple=function(t){for(var r=0,n=0;n<t.length;n++)r+=t[n];return r},t.product=function(t){for(var r=1,n=0;n<t.length;n++)r*=t[n];return r},t.quantile=g,t.quantileSorted=s,t.quantileRank=function(t,r){return M(u(t),r)},t.quantileRankSorted=M,t.interquartileRange=m,t.iqr=m,t.medianAbsoluteDeviation=b,t.mad=b,t.chunk=function(t,r){var n=[];if(r<1)throw new Error("chunk size must be a positive number");if(Math.floor(r)!==r)throw new Error("chunk size must be an integer");for(var e=0;e<t.length;e+=r)n.push(t.slice(e,e+r));return n},t.sampleWithReplacement=function(t,r,n){if(0===t.length)return[];n=n||Math.random;for(var e=t.length,a=[],o=0;o<r;o++){var i=Math.floor(n()*e);a.push(t[i])}return a},t.shuffle=E,t.shuffleInPlace=q,t.sample=function(t,r,n){return E(t,n).slice(0,r)},t.ckmeans=function(t,r){if(r>t.length)throw new Error("cannot generate more classes than there are data values");var n=u(t);if(1===y(n))return[n];var e=S(r,n.length),a=S(r,n.length);!function(t,r,n){for(var e=r[0].length,a=t[Math.floor(e/2)],o=[],i=[],u=0,h=void 0;u<e;++u)h=t[u]-a,0===u?(o.push(h),i.push(h*h)):(o.push(o[u-1]+h),i.push(i[u-1]+h*h)),r[0][u]=x(0,u,o,i),n[0][u]=0;for(var f=1;f<r.length;++f)k(f<r.length-1?f:e-1,e-1,f,r,n,o,i)}(n,e,a);for(var o=[],i=a[0].length-1,h=a.length-1;h>=0;h--){var f=a[h][i];o[h]=n.slice(f,i+1),h>0&&(i=f-1)}return o},t.uniqueCountSorted=y,t.sumNthPowerDeviations=e,t.equalIntervalBreaks=function(t,r){if(t.length<2)return t;for(var n=h(t),e=f(t),a=[n],o=(e-n)/r,i=1;i<r;i++)a.push(a[0]+o*i);return a.push(e),a},t.sampleCovariance=I,t.sampleCorrelation=function(t,r){return I(t,r)/D(t)/D(r)},t.sampleVariance=P,t.sampleStandardDeviation=D,t.sampleSkewness=function(t){if(t.length<3)throw new Error("sampleSkewness requires at least three data points");for(var r,e=n(t),a=0,o=0,i=0;i<t.length;i++)a+=(r=t[i]-e)*r,o+=r*r*r;var u=Math.sqrt(a/(t.length-1)),h=t.length;return h*o/((h-1)*(h-2)*Math.pow(u,3))},t.sampleKurtosis=function(t){var r=t.length;if(r<4)throw new Error("sampleKurtosis requires at least four data points");for(var e,a=n(t),o=0,i=0,u=0;u<r;u++)o+=(e=t[u]-a)*e,i+=e*e*e*e;return(r-1)/((r-2)*(r-3))*(r*(r+1)*i/(o*o)-3*(r-1))},t.permutationsHeap=function(t){for(var r=new Array(t.length),n=[t.slice()],e=0;e<t.length;e++)r[e]=0;for(var a=0;a<t.length;)if(r[a]<a){var o=0;a%2!=0&&(o=r[a]);var i=t[o];t[o]=t[a],t[a]=i,n.push(t.slice()),r[a]++,a=0}else r[a]=0,a++;return n},t.combinations=function t(r,n){var e,a,o,i,u=[];for(e=0;e<r.length;e++)if(1===n)u.push([r[e]]);else for(o=t(r.slice(e+1,r.length),n-1),a=0;a<o.length;a++)(i=o[a]).unshift(r[e]),u.push(i);return u},t.combinationsReplacement=function t(r,n){for(var e=[],a=0;a<r.length;a++)if(1===n)e.push([r[a]]);else for(var o=t(r.slice(a,r.length),n-1),i=0;i<o.length;i++)e.push([r[a]].concat(o[i]));return e},t.addToMean=function(t,r,n){return t+(n-t)/(r+1)},t.combineMeans=C,t.combineVariances=function(t,r,n,e,a,o){var i=C(r,n,a,o);return(n*(t+Math.pow(r-i,2))+o*(e+Math.pow(a-i,2)))/(n+o)},t.geometricMean=function(t){if(0===t.length)throw new Error("geometricMean requires at least one data point");for(var r=1,n=0;n<t.length;n++){if(t[n]<=0)throw new Error("geometricMean requires only positive numbers as input");r*=t[n]}return Math.pow(r,1/t.length)},t.harmonicMean=function(t){if(0===t.length)throw new Error("harmonicMean requires at least one data point");for(var r=0,n=0;n<t.length;n++){if(t[n]<=0)throw new Error("harmonicMean requires only positive numbers as input");r+=1/t[n]}return t.length/r},t.average=n,t.mean=n,t.median=d,t.medianSorted=function(t){return s(t,.5)},t.subtractFromMean=function(t,r,n){return(t*r-n)/(r-1)},t.rootMeanSquare=T,t.rms=T,t.variance=a,t.tTest=function(t,r){return(n(t)-r)/(o(t)/Math.sqrt(t.length))},t.tTestTwoSample=function(t,r,e){var a=t.length,o=r.length;if(!a||!o)return null;e||(e=0);var i=n(t),u=n(r),h=P(t),f=P(r);return"number"==typeof i&&"number"==typeof u&&"number"==typeof h&&"number"==typeof f?(i-u-e)/Math.sqrt(((a-1)*h+(o-1)*f)/(a+o-2)*(1/a+1/o)):void 0},t.BayesianClassifier=N,t.bayesian=N,t.PerceptronModel=R,t.perceptron=R,t.epsilon=F,t.factorial=A,t.gamma=function t(r){if(Number.isInteger(r))return r<=0?NaN:A(r-1);if(--r<0)return Math.PI/(Math.sin(Math.PI*-r)*t(-r));var n=r+.25;return Math.pow(r/Math.E,r)*Math.sqrt(2*Math.PI*(r+1/6))*(1+1/144/Math.pow(n,2)-1/12960/Math.pow(n,3)-257/207360/Math.pow(n,4)-52/2612736/Math.pow(n,5)+5741173/9405849600/Math.pow(n,6)+37529/18811699200/Math.pow(n,7))},t.gammaln=function(t){if(t<=0)return Infinity;t--;for(var r=_[0],n=1;n<15;n++)r+=_[n]/(t+n);var e=z+.5+t;return V+Math.log(r)-e+(t+.5)*Math.log(e)},t.bernoulliDistribution=function(t){if(t<0||t>1)throw new Error("bernoulliDistribution requires probability to be between 0 and 1 inclusive");return[1-t,t]},t.binomialDistribution=function(t,r){if(!(r<0||r>1||t<=0||t%1!=0)){var n=0,e=0,a=[],o=1;do{a[n]=o*Math.pow(r,n)*Math.pow(1-r,t-n),e+=a[n],o=o*(t-++n+1)/n}while(e<1-F);return a}},t.poissonDistribution=function(t){if(!(t<=0)){var r=0,n=0,e=[],a=1;do{e[r]=Math.exp(-t)*Math.pow(t,r)/a,n+=e[r],a*=++r}while(n<1-F);return e}},t.chiSquaredDistributionTable=B,t.chiSquaredGoodnessOfFit=function(t,r,e){for(var a=0,o=r(n(t)),i=[],u=[],h=0;h<t.length;h++)void 0===i[t[h]]&&(i[t[h]]=0),i[t[h]]++;for(var f=0;f<i.length;f++)void 0===i[f]&&(i[f]=0);for(var s in o)s in i&&(u[+s]=o[s]*t.length);for(var l=u.length-1;l>=0;l--)u[l]<3&&(u[l-1]+=u[l],u.pop(),i[l-1]+=i[l],i.pop());for(var c=0;c<i.length;c++)a+=Math.pow(i[c]-u[c],2)/u[c];return B[i.length-1-1][e]<a},t.kernelDensityEstimation=G,t.kde=G,t.zScore=function(t,r,n){return(t-r)/n},t.cumulativeStdNormalProbability=function(t){var r=Math.abs(t),n=Math.min(Math.round(100*r),O.length-1);return t>=0?O[n]:+(1-O[n]).toFixed(4)},t.standardNormalTable=O,t.errorFunction=J,t.erf=J,t.inverseErrorFunction=Q,t.probit=function(t){return 0===t?t=F:t>=1&&(t=1-F),Math.sqrt(2)*Q(2*t-1)},t.permutationTest=function(t,r,e,a){if(void 0===a&&(a=1e4),void 0===e&&(e="two_side"),"two_side"!==e&&"greater"!==e&&"less"!==e)throw new Error("`alternative` must be either 'two_side', 'greater', or 'less'");for(var o=n(t)-n(r),i=new Array(a),u=t.concat(r),h=Math.floor(u.length/2),f=0;f<a;f++){q(u);var s=u.slice(0,h),l=u.slice(h,u.length),c=n(s)-n(l);i[f]=c}var g=0;if("two_side"===e)for(var v=0;v<=a;v++)Math.abs(i[v])>=Math.abs(o)&&(g+=1);else if("greater"===e)for(var p=0;p<=a;p++)i[p]>=o&&(g+=1);else for(var w=0;w<=a;w++)i[w]<=o&&(g+=1);return g/a},t.bisect=function(t,r,n,e,a){if("function"!=typeof t)throw new TypeError("func must be a function");for(var o=0;o<e;o++){var i=(r+n)/2;if(0===t(i)||Math.abs((n-r)/2)<a)return i;X(t(i))===X(t(r))?r=i:n=i}throw new Error("maximum number of iterations exceeded")},t.quickselect=l,t.sign=X,t.numericSort=u});
//# sourceMappingURL=simple-statistics.min.js.map
{
"name": "simple-statistics",
"version": "7.0.0",
"version": "7.0.1",
"description": "Simple Statistics",

@@ -5,0 +5,0 @@ "author": "Tom MacWright <tom@macwright.org> (http://macwright.org/)",

@@ -39,4 +39,4 @@ # Simple Statistics

available globally as the variable `ss`. You can reassign this variable to
another name if you want to, but doing so is optional. <pre><script src='https://unpkg.com/simple-statistics@7.0.0/dist/simple-statistics.min.js' /></pre>
* `https://unpkg.com/simple-statistics@7.0.0/dist/simple-statistics.min.js`
another name if you want to, but doing so is optional. <pre><script src='https://unpkg.com/simple-statistics@7.0.1/dist/simple-statistics.min.js' /></pre>
* `https://unpkg.com/simple-statistics@7.0.1/dist/simple-statistics.min.js`
* **I want to use ES6 modules in a browser and I'm [willing to only support new browsers](https://caniuse.com/#feat=es6-module) to do it**

@@ -48,3 +48,3 @@ * This module works great with the [`?module`](https://unpkg.com/#/query-parameters) query parameter of unpkg. If you

<script type='module'>
import {min} from "https://unpkg.com/simple-statistics@7.0.0/index.js?module"
import {min} from "https://unpkg.com/simple-statistics@7.0.1/index.js?module"
console.log(min([1, 2, 3]))

@@ -51,0 +51,0 @@ </script>

@@ -8,2 +8,3 @@ /**

* This function returns a numerical approximation to the exact value.
* It uses Horner's method to evaluate the polynomial of τ (tau).
*

@@ -20,13 +21,17 @@ * @param {number} x input

Math.exp(
-Math.pow(x, 2) -
1.26551223 +
1.00002368 * t +
0.37409196 * Math.pow(t, 2) +
0.09678418 * Math.pow(t, 3) -
0.18628806 * Math.pow(t, 4) +
0.27886807 * Math.pow(t, 5) -
1.13520398 * Math.pow(t, 6) +
1.48851587 * Math.pow(t, 7) -
0.82215223 * Math.pow(t, 8) +
0.17087277 * Math.pow(t, 9)
-x * x +
((((((((0.17087277 * t - 0.82215223) * t + 1.48851587) * t -
1.13520398) *
t +
0.27886807) *
t -
0.18628806) *
t +
0.09678418) *
t +
0.37409196) *
t +
1.00002368) *
t -
1.26551223
);

@@ -33,0 +38,0 @@ if (x >= 0) {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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