UNPKG

oda-framework

Version:

It's an ES Progressive Framework based on the technology of Web Components and designed especially for creating custom UI/UX of any complexity for web and cross-platform PWA mobile applications.

13 lines (10 loc) 299 kB
'use strict'; if (! jSuites && typeof(require) === 'function') { var jSuites = require('jsuites'); } ;(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : global.formula = factory(); }(this, (function () { var Formula;!function(){var n={765:function(n,t){var r;r=function(n){n.version="1.0.2";var t=Math;function r(n,t){for(var r=0,e=0;r<n.length;++r)e=t*e+n[r];return e}function e(n,t,r,e,o){if(0===t)return r;if(1===t)return e;for(var i=2/n,u=e,a=1;a<t;++a)u=e*a*i+o*r,r=e,e=u;return u}function o(n,t,r,o,i){return function(r,u){if(o){if(0===r)return 1==o?-1/0:1/0;if(r<0)return NaN}return 0===u?n(r):1===u?t(r):u<0?NaN:e(r,u|=0,n(r),t(r),i)}}var i,u,a,f,l,c,s,h,g,p,m,d,v,E=function(){var n=.636619772,o=[57568490574,-13362590354,651619640.7,-11214424.18,77392.33017,-184.9052456].reverse(),i=[57568490411,1029532985,9494680.718,59272.64853,267.8532712,1].reverse(),u=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),a=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34935152e-8].reverse();function f(e){var f=0,l=0,c=0,s=e*e;if(e<8)f=(l=r(o,s))/(c=r(i,s));else{var h=e-.785398164;l=r(u,s=64/s),c=r(a,s),f=t.sqrt(n/e)*(t.cos(h)*l-t.sin(h)*c*8/e)}return f}var l=[72362614232,-7895059235,242396853.1,-2972611.439,15704.4826,-30.16036606].reverse(),c=[144725228442,2300535178,18583304.74,99447.43394,376.9991397,1].reverse(),s=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),h=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse();function g(e){var o=0,i=0,u=0,a=e*e,f=t.abs(e)-2.356194491;return Math.abs(e)<8?o=(i=e*r(l,a))/(u=r(c,a)):(i=r(s,a=64/a),u=r(h,a),o=t.sqrt(n/t.abs(e))*(t.cos(f)*i-t.sin(f)*u*8/t.abs(e)),e<0&&(o=-o)),o}return function n(r,o){if(o=Math.round(o),!isFinite(r))return isNaN(r)?r:0;if(o<0)return(o%2?-1:1)*n(r,-o);if(r<0)return(o%2?-1:1)*n(-r,o);if(0===o)return f(r);if(1===o)return g(r);if(0===r)return 0;var i=0;if(r>o)i=e(r,o,f(r),g(r),-1);else{for(var u=!1,a=0,l=0,c=1,s=0,h=2/r,p=2*t.floor((o+t.floor(t.sqrt(40*o)))/2);p>0;p--)s=p*h*c-a,a=c,c=s,t.abs(c)>1e10&&(c*=1e-10,a*=1e-10,i*=1e-10,l*=1e-10),u&&(l+=c),u=!u,p==o&&(i=a);i/=l=2*l-c}return i}}(),M=(i=.636619772,u=[-2957821389,7062834065,-512359803.6,10879881.29,-86327.92757,228.4622733].reverse(),a=[40076544269,745249964.8,7189466.438,47447.2647,226.1030244,1].reverse(),f=[1,-.001098628627,2734510407e-14,-2073370639e-15,2.093887211e-7].reverse(),l=[-.01562499995,.0001430488765,-6911147651e-15,7.621095161e-7,-9.34945152e-8].reverse(),c=[-4900604943e3,127527439e4,-51534381390,734926455.1,-4237922.726,8511.937935].reverse(),s=[249958057e5,424441966400,3733650367,22459040.02,102042.605,354.9632885,1].reverse(),h=[1,.00183105,-3516396496e-14,2457520174e-15,-2.40337019e-7].reverse(),g=[.04687499995,-.0002002690873,8449199096e-15,-8.8228987e-7,1.05787412e-7].reverse(),o((function(n){var e=0,o=0,c=0,s=n*n,h=n-.785398164;return n<8?e=(o=r(u,s))/(c=r(a,s))+i*E(n,0)*t.log(n):(o=r(f,s=64/s),c=r(l,s),e=t.sqrt(i/n)*(t.sin(h)*o+t.cos(h)*c*8/n)),e}),(function(n){var e=0,o=0,u=0,a=n*n,f=n-2.356194491;return n<8?e=(o=n*r(c,a))/(u=r(s,a))+i*(E(n,1)*t.log(n)-1/n):(o=r(h,a=64/a),u=r(g,a),e=t.sqrt(i/n)*(t.sin(f)*o+t.cos(f)*u*8/n)),e}),0,1,-1)),N=(p=[1,3.5156229,3.0899424,1.2067492,.2659732,.0360768,.0045813].reverse(),m=[.39894228,.01328592,.00225319,-.00157565,.00916281,-.02057706,.02635537,-.01647633,.00392377].reverse(),d=[.5,.87890594,.51498869,.15084934,.02658733,.00301532,32411e-8].reverse(),v=[.39894228,-.03988024,-.00362018,.00163801,-.01031555,.02282967,-.02895312,.01787654,-.00420059].reverse(),function n(e,o){if(0===(o=Math.round(o)))return function(n){return n<=3.75?r(p,n*n/14.0625):t.exp(t.abs(n))/t.sqrt(t.abs(n))*r(m,3.75/t.abs(n))}(e);if(1===o)return function(n){return n<3.75?n*r(d,n*n/14.0625):(n<0?-1:1)*t.exp(t.abs(n))/t.sqrt(t.abs(n))*r(v,3.75/t.abs(n))}(e);if(o<0)return NaN;if(0===t.abs(e))return 0;if(e==1/0)return 1/0;var i,u=0,a=2/t.abs(e),f=0,l=1,c=0;for(i=2*t.round((o+t.round(t.sqrt(40*o)))/2);i>0;i--)c=i*a*l+f,f=l,l=c,t.abs(l)>1e10&&(l*=1e-10,f*=1e-10,u*=1e-10),i==o&&(u=f);return u*=n(e,0)/l,e<0&&o%2?-u:u}),w=function(){var n=[-.57721566,.4227842,.23069756,.0348859,.00262698,1075e-7,74e-7].reverse(),e=[1.25331414,-.07832358,.02189568,-.01062446,.00587872,-.0025154,53208e-8].reverse(),i=[1,.15443144,-.67278579,-.18156897,-.01919402,-.00110404,-4686e-8].reverse(),u=[1.25331414,.23498619,-.0365562,.01504268,-.00780353,.00325614,-68245e-8].reverse();return o((function(o){return o<=2?-t.log(o/2)*N(o,0)+r(n,o*o/4):t.exp(-o)/t.sqrt(o)*r(e,2/o)}),(function(n){return n<=2?t.log(n/2)*N(n,1)+1/n*r(i,n*n/4):t.exp(-n)/t.sqrt(n)*r(u,2/n)}),0,2,1)}();n.besselj=E,n.bessely=M,n.besseli=N,n.besselk=w},"undefined"==typeof DO_NOT_EXPORT_BESSEL?r(t):r({})},162:function(n){var t;n.exports=(t=function(n,t){var r=Array.prototype.concat,e=Array.prototype.slice,o=Object.prototype.toString;function i(t,r){var e=t>r?t:r;return n.pow(10,17-~~(n.log(e>0?e:-e)*n.LOG10E))}var u=Array.isArray||function(n){return"[object Array]"===o.call(n)};function a(n){return"[object Function]"===o.call(n)}function f(n){return"number"==typeof n&&n-n==0}function l(){return new l._init(arguments)}function c(){return 0}function s(){return 1}function h(n,t){return n===t?1:0}l.fn=l.prototype,l._init=function(n){if(u(n[0]))if(u(n[0][0])){a(n[1])&&(n[0]=l.map(n[0],n[1]));for(var t=0;t<n[0].length;t++)this[t]=n[0][t];this.length=n[0].length}else this[0]=a(n[1])?l.map(n[0],n[1]):n[0],this.length=1;else if(f(n[0]))this[0]=l.seq.apply(null,n),this.length=1;else{if(n[0]instanceof l)return l(n[0].toArray());this[0]=[],this.length=1}return this},l._init.prototype=l.prototype,l._init.constructor=l,l.utils={calcRdx:i,isArray:u,isFunction:a,isNumber:f,toVector:function(n){return r.apply([],n)}},l._random_fn=n.random,l.setRandom=function(n){if("function"!=typeof n)throw new TypeError("fn is not a function");l._random_fn=n},l.extend=function(n){var t,r;if(1===arguments.length){for(r in n)l[r]=n[r];return this}for(t=1;t<arguments.length;t++)for(r in arguments[t])n[r]=arguments[t][r];return n},l.rows=function(n){return n.length||1},l.cols=function(n){return n[0].length||1},l.dimensions=function(n){return{rows:l.rows(n),cols:l.cols(n)}},l.row=function(n,t){return u(t)?t.map((function(t){return l.row(n,t)})):n[t]},l.rowa=function(n,t){return l.row(n,t)},l.col=function(n,t){if(u(t)){var r=l.arange(n.length).map((function(){return new Array(t.length)}));return t.forEach((function(t,e){l.arange(n.length).forEach((function(o){r[o][e]=n[o][t]}))})),r}for(var e=new Array(n.length),o=0;o<n.length;o++)e[o]=[n[o][t]];return e},l.cola=function(n,t){return l.col(n,t).map((function(n){return n[0]}))},l.diag=function(n){for(var t=l.rows(n),r=new Array(t),e=0;e<t;e++)r[e]=[n[e][e]];return r},l.antidiag=function(n){for(var t=l.rows(n)-1,r=new Array(t),e=0;t>=0;t--,e++)r[e]=[n[e][t]];return r},l.transpose=function(n){var t,r,e,o,i,a=[];for(u(n[0])||(n=[n]),r=n.length,e=n[0].length,i=0;i<e;i++){for(t=new Array(r),o=0;o<r;o++)t[o]=n[o][i];a.push(t)}return 1===a.length?a[0]:a},l.map=function(n,t,r){var e,o,i,a,f;for(u(n[0])||(n=[n]),o=n.length,i=n[0].length,a=r?n:new Array(o),e=0;e<o;e++)for(a[e]||(a[e]=new Array(i)),f=0;f<i;f++)a[e][f]=t(n[e][f],e,f);return 1===a.length?a[0]:a},l.cumreduce=function(n,t,r){var e,o,i,a,f;for(u(n[0])||(n=[n]),o=n.length,i=n[0].length,a=r?n:new Array(o),e=0;e<o;e++)for(a[e]||(a[e]=new Array(i)),i>0&&(a[e][0]=n[e][0]),f=1;f<i;f++)a[e][f]=t(a[e][f-1],n[e][f]);return 1===a.length?a[0]:a},l.alter=function(n,t){return l.map(n,t,!0)},l.create=function(n,t,r){var e,o,i=new Array(n);for(a(t)&&(r=t,t=n),e=0;e<n;e++)for(i[e]=new Array(t),o=0;o<t;o++)i[e][o]=r(e,o);return i},l.zeros=function(n,t){return f(t)||(t=n),l.create(n,t,c)},l.ones=function(n,t){return f(t)||(t=n),l.create(n,t,s)},l.rand=function(n,t){return f(t)||(t=n),l.create(n,t,l._random_fn)},l.identity=function(n,t){return f(t)||(t=n),l.create(n,t,h)},l.symmetric=function(n){var t,r,e=n.length;if(n.length!==n[0].length)return!1;for(t=0;t<e;t++)for(r=0;r<e;r++)if(n[r][t]!==n[t][r])return!1;return!0},l.clear=function(n){return l.alter(n,c)},l.seq=function(n,t,r,e){a(e)||(e=!1);var o,u=[],f=i(n,t),l=(t*f-n*f)/((r-1)*f),c=n;for(o=0;c<=t&&o<r;c=(n*f+l*f*++o)/f)u.push(e?e(c,o):c);return u},l.arange=function(n,r,e){var o,i=[];if(e=e||1,r===t&&(r=n,n=0),n===r||0===e)return[];if(n<r&&e<0)return[];if(n>r&&e>0)return[];if(e>0)for(o=n;o<r;o+=e)i.push(o);else for(o=n;o>r;o+=e)i.push(o);return i},l.slice=function(){function n(n,r,e,o){var i,u=[],a=n.length;if(r===t&&e===t&&o===t)return l.copy(n);if(o=o||1,(r=(r=r||0)>=0?r:a+r)===(e=(e=e||n.length)>=0?e:a+e)||0===o)return[];if(r<e&&o<0)return[];if(r>e&&o>0)return[];if(o>0)for(i=r;i<e;i+=o)u.push(n[i]);else for(i=r;i>e;i+=o)u.push(n[i]);return u}return function(t,r){var e,o;return f((r=r||{}).row)?f(r.col)?t[r.row][r.col]:n(l.rowa(t,r.row),(e=r.col||{}).start,e.end,e.step):f(r.col)?n(l.cola(t,r.col),(o=r.row||{}).start,o.end,o.step):(o=r.row||{},e=r.col||{},n(t,o.start,o.end,o.step).map((function(t){return n(t,e.start,e.end,e.step)})))}}(),l.sliceAssign=function(r,e,o){var i,u;if(f(e.row)){if(f(e.col))return r[e.row][e.col]=o;e.col=e.col||{},e.col.start=e.col.start||0,e.col.end=e.col.end||r[0].length,e.col.step=e.col.step||1,i=l.arange(e.col.start,n.min(r.length,e.col.end),e.col.step);var a=e.row;return i.forEach((function(n,t){r[a][n]=o[t]})),r}if(f(e.col)){e.row=e.row||{},e.row.start=e.row.start||0,e.row.end=e.row.end||r.length,e.row.step=e.row.step||1,u=l.arange(e.row.start,n.min(r[0].length,e.row.end),e.row.step);var c=e.col;return u.forEach((function(n,t){r[n][c]=o[t]})),r}return o[0].length===t&&(o=[o]),e.row.start=e.row.start||0,e.row.end=e.row.end||r.length,e.row.step=e.row.step||1,e.col.start=e.col.start||0,e.col.end=e.col.end||r[0].length,e.col.step=e.col.step||1,u=l.arange(e.row.start,n.min(r.length,e.row.end),e.row.step),i=l.arange(e.col.start,n.min(r[0].length,e.col.end),e.col.step),u.forEach((function(n,t){i.forEach((function(e,i){r[n][e]=o[t][i]}))})),r},l.diagonal=function(n){var t=l.zeros(n.length,n.length);return n.forEach((function(n,r){t[r][r]=n})),t},l.copy=function(n){return n.map((function(n){return f(n)?n:n.map((function(n){return n}))}))};var g=l.prototype;return g.length=0,g.push=Array.prototype.push,g.sort=Array.prototype.sort,g.splice=Array.prototype.splice,g.slice=Array.prototype.slice,g.toArray=function(){return this.length>1?e.call(this):e.call(this)[0]},g.map=function(n,t){return l(l.map(this,n,t))},g.cumreduce=function(n,t){return l(l.cumreduce(this,n,t))},g.alter=function(n){return l.alter(this,n),this},function(n){for(var t=0;t<n.length;t++)!function(n){g[n]=function(t){var r,e=this;return t?(setTimeout((function(){t.call(e,g[n].call(e))})),this):(r=l[n](this),u(r)?l(r):r)}}(n[t])}("transpose clear symmetric rows cols dimensions diag antidiag".split(" ")),function(n){for(var t=0;t<n.length;t++)!function(n){g[n]=function(t,r){var e=this;return r?(setTimeout((function(){r.call(e,g[n].call(e,t))})),this):l(l[n](this,t))}}(n[t])}("row col".split(" ")),function(n){for(var t=0;t<n.length;t++)!function(n){g[n]=function(){return l(l[n].apply(null,arguments))}}(n[t])}("create zeros ones rand identity".split(" ")),l}(Math),function(n,t){var r=n.utils.isFunction;function e(n,t){return n-t}function o(n,r,e){return t.max(r,t.min(n,e))}n.sum=function(n){for(var t=0,r=n.length;--r>=0;)t+=n[r];return t},n.sumsqrd=function(n){for(var t=0,r=n.length;--r>=0;)t+=n[r]*n[r];return t},n.sumsqerr=function(t){for(var r,e=n.mean(t),o=0,i=t.length;--i>=0;)o+=(r=t[i]-e)*r;return o},n.sumrow=function(n){for(var t=0,r=n.length;--r>=0;)t+=n[r];return t},n.product=function(n){for(var t=1,r=n.length;--r>=0;)t*=n[r];return t},n.min=function(n){for(var t=n[0],r=0;++r<n.length;)n[r]<t&&(t=n[r]);return t},n.max=function(n){for(var t=n[0],r=0;++r<n.length;)n[r]>t&&(t=n[r]);return t},n.unique=function(n){for(var t={},r=[],e=0;e<n.length;e++)t[n[e]]||(t[n[e]]=!0,r.push(n[e]));return r},n.mean=function(t){return n.sum(t)/t.length},n.meansqerr=function(t){return n.sumsqerr(t)/t.length},n.geomean=function(r){var e=r.map(t.log),o=n.mean(e);return t.exp(o)},n.median=function(n){var t=n.length,r=n.slice().sort(e);return 1&t?r[t/2|0]:(r[t/2-1]+r[t/2])/2},n.cumsum=function(t){return n.cumreduce(t,(function(n,t){return n+t}))},n.cumprod=function(t){return n.cumreduce(t,(function(n,t){return n*t}))},n.diff=function(n){var t,r=[],e=n.length;for(t=1;t<e;t++)r.push(n[t]-n[t-1]);return r},n.rank=function(n){var t,r=[],o={};for(t=0;t<n.length;t++)o[f=n[t]]?o[f]++:(o[f]=1,r.push(f));var i=r.sort(e),u={},a=1;for(t=0;t<i.length;t++){var f,l=o[f=i[t]],c=(a+(a+l-1))/2;u[f]=c,a+=l}return n.map((function(n){return u[n]}))},n.mode=function(n){var t,r=n.length,o=n.slice().sort(e),i=1,u=0,a=0,f=[];for(t=0;t<r;t++)o[t]===o[t+1]?i++:(i>u?(f=[o[t]],u=i,a=0):i===u&&(f.push(o[t]),a++),i=1);return 0===a?f[0]:f},n.range=function(t){return n.max(t)-n.min(t)},n.variance=function(t,r){return n.sumsqerr(t)/(t.length-(r?1:0))},n.pooledvariance=function(t){return t.reduce((function(t,r){return t+n.sumsqerr(r)}),0)/(t.reduce((function(n,t){return n+t.length}),0)-t.length)},n.deviation=function(t){for(var r=n.mean(t),e=t.length,o=new Array(e),i=0;i<e;i++)o[i]=t[i]-r;return o},n.stdev=function(r,e){return t.sqrt(n.variance(r,e))},n.pooledstdev=function(r){return t.sqrt(n.pooledvariance(r))},n.meandev=function(r){for(var e=n.mean(r),o=[],i=r.length-1;i>=0;i--)o.push(t.abs(r[i]-e));return n.mean(o)},n.meddev=function(r){for(var e=n.median(r),o=[],i=r.length-1;i>=0;i--)o.push(t.abs(r[i]-e));return n.median(o)},n.coeffvar=function(t){return n.stdev(t)/n.mean(t)},n.quartiles=function(n){var r=n.length,o=n.slice().sort(e);return[o[t.round(r/4)-1],o[t.round(r/2)-1],o[t.round(3*r/4)-1]]},n.quantiles=function(n,r,i,u){var a,f,l,c,s,h=n.slice().sort(e),g=[r.length],p=n.length;for(void 0===i&&(i=3/8),void 0===u&&(u=3/8),a=0;a<r.length;a++)l=p*(f=r[a])+(i+f*(1-i-u)),c=t.floor(o(l,1,p-1)),s=o(l-c,0,1),g[a]=(1-s)*h[c-1]+s*h[c];return g},n.percentile=function(n,t,r){var o=n.slice().sort(e),i=t*(o.length+(r?1:-1))+(r?0:1),u=parseInt(i),a=i-u;return u+1<o.length?o[u-1]+a*(o[u]-o[u-1]):o[u-1]},n.percentileOfScore=function(n,t,r){var e,o,i=0,u=n.length,a=!1;for("strict"===r&&(a=!0),o=0;o<u;o++)e=n[o],(a&&e<t||!a&&e<=t)&&i++;return i/u},n.histogram=function(r,e){e=e||4;var o,i=n.min(r),u=(n.max(r)-i)/e,a=r.length,f=[];for(o=0;o<e;o++)f[o]=0;for(o=0;o<a;o++)f[t.min(t.floor((r[o]-i)/u),e-1)]+=1;return f},n.covariance=function(t,r){var e,o=n.mean(t),i=n.mean(r),u=t.length,a=new Array(u);for(e=0;e<u;e++)a[e]=(t[e]-o)*(r[e]-i);return n.sum(a)/(u-1)},n.corrcoeff=function(t,r){return n.covariance(t,r)/n.stdev(t,1)/n.stdev(r,1)},n.spearmancoeff=function(t,r){return t=n.rank(t),r=n.rank(r),n.corrcoeff(t,r)},n.stanMoment=function(r,e){for(var o=n.mean(r),i=n.stdev(r),u=r.length,a=0,f=0;f<u;f++)a+=t.pow((r[f]-o)/i,e);return a/r.length},n.skewness=function(t){return n.stanMoment(t,3)},n.kurtosis=function(t){return n.stanMoment(t,4)-3};var i=n.prototype;!function(t){for(var e=0;e<t.length;e++)!function(t){i[t]=function(e,o){var u=[],a=0,f=this;if(r(e)&&(o=e,e=!1),o)return setTimeout((function(){o.call(f,i[t].call(f,e))})),this;if(this.length>1){for(f=!0===e?this:this.transpose();a<f.length;a++)u[a]=n[t](f[a]);return u}return n[t](this[0],e)}}(t[e])}("cumsum cumprod".split(" ")),function(t){for(var e=0;e<t.length;e++)!function(t){i[t]=function(e,o){var u=[],a=0,f=this;if(r(e)&&(o=e,e=!1),o)return setTimeout((function(){o.call(f,i[t].call(f,e))})),this;if(this.length>1){for("sumrow"!==t&&(f=!0===e?this:this.transpose());a<f.length;a++)u[a]=n[t](f[a]);return!0===e?n[t](n.utils.toVector(u)):u}return n[t](this[0],e)}}(t[e])}("sum sumsqrd sumsqerr sumrow product min max unique mean meansqerr geomean median diff rank mode range variance deviation stdev meandev meddev coeffvar quartiles histogram skewness kurtosis".split(" ")),function(t){for(var e=0;e<t.length;e++)!function(t){i[t]=function(){var e,o=[],u=0,a=this,f=Array.prototype.slice.call(arguments);if(r(f[f.length-1])){e=f[f.length-1];var l=f.slice(0,f.length-1);return setTimeout((function(){e.call(a,i[t].apply(a,l))})),this}e=void 0;var c=function(r){return n[t].apply(a,[r].concat(f))};if(this.length>1){for(a=a.transpose();u<a.length;u++)o[u]=c(a[u]);return o}return c(this[0])}}(t[e])}("quantiles percentileOfScore".split(" "))}(t,Math),function(n,t){n.gammaln=function(n){var r,e,o,i=0,u=[76.18009172947146,-86.50532032941678,24.01409824083091,-1.231739572450155,.001208650973866179,-5395239384953e-18],a=1.000000000190015;for(o=(e=r=n)+5.5,o-=(r+.5)*t.log(o);i<6;i++)a+=u[i]/++e;return t.log(2.5066282746310007*a/r)-o},n.loggam=function(n){var r,e,o,i,u,a,f,l=[.08333333333333333,-.002777777777777778,.0007936507936507937,-.0005952380952380952,.0008417508417508418,-.001917526917526918,.00641025641025641,-.02955065359477124,.1796443723688307,-1.3924322169059];if(r=n,f=0,1==n||2==n)return 0;for(n<=7&&(r=n+(f=t.floor(7-n))),e=1/(r*r),o=2*t.PI,u=l[9],a=8;a>=0;a--)u*=e,u+=l[a];if(i=u/r+.5*t.log(o)+(r-.5)*t.log(r)-r,n<=7)for(a=1;a<=f;a++)i-=t.log(r-1),r-=1;return i},n.gammafn=function(n){var r,e,o,i,u=[-1.716185138865495,24.76565080557592,-379.80425647094563,629.3311553128184,866.9662027904133,-31451.272968848367,-36144.413418691176,66456.14382024054],a=[-30.8402300119739,315.35062697960416,-1015.1563674902192,-3107.771671572311,22538.11842098015,4755.846277527881,-134659.9598649693,-115132.2596755535],f=!1,l=0,c=0,s=0,h=n;if(n>171.6243769536076)return 1/0;if(h<=0){if(!(i=h%1+36e-17))return 1/0;f=(1&h?-1:1)*t.PI/t.sin(t.PI*i),h=1-h}for(o=h,e=h<1?h++:(h-=l=(0|h)-1)-1,r=0;r<8;++r)s=(s+u[r])*e,c=c*e+a[r];if(i=s/c+1,o<h)i/=o;else if(o>h)for(r=0;r<l;++r)i*=h,h++;return f&&(i=f/i),i},n.gammap=function(t,r){return n.lowRegGamma(t,r)*n.gammafn(t)},n.lowRegGamma=function(r,e){var o,i=n.gammaln(r),u=r,a=1/r,f=a,l=e+1-r,c=1/1e-30,s=1/l,h=s,g=1,p=-~(8.5*t.log(r>=1?r:1/r)+.4*r+17);if(e<0||r<=0)return NaN;if(e<r+1){for(;g<=p;g++)a+=f*=e/++u;return a*t.exp(-e+r*t.log(e)-i)}for(;g<=p;g++)h*=(s=1/(s=(o=-g*(g-r))*s+(l+=2)))*(c=l+o/c);return 1-h*t.exp(-e+r*t.log(e)-i)},n.factorialln=function(t){return t<0?NaN:n.gammaln(t+1)},n.factorial=function(t){return t<0?NaN:n.gammafn(t+1)},n.combination=function(r,e){return r>170||e>170?t.exp(n.combinationln(r,e)):n.factorial(r)/n.factorial(e)/n.factorial(r-e)},n.combinationln=function(t,r){return n.factorialln(t)-n.factorialln(r)-n.factorialln(t-r)},n.permutation=function(t,r){return n.factorial(t)/n.factorial(t-r)},n.betafn=function(r,e){if(!(r<=0||e<=0))return r+e>170?t.exp(n.betaln(r,e)):n.gammafn(r)*n.gammafn(e)/n.gammafn(r+e)},n.betaln=function(t,r){return n.gammaln(t)+n.gammaln(r)-n.gammaln(t+r)},n.betacf=function(n,r,e){var o,i,u,a,f=1e-30,l=1,c=r+e,s=r+1,h=r-1,g=1,p=1-c*n/s;for(t.abs(p)<f&&(p=f),a=p=1/p;l<=100&&(p=1+(i=l*(e-l)*n/((h+(o=2*l))*(r+o)))*p,t.abs(p)<f&&(p=f),g=1+i/g,t.abs(g)<f&&(g=f),a*=(p=1/p)*g,p=1+(i=-(r+l)*(c+l)*n/((r+o)*(s+o)))*p,t.abs(p)<f&&(p=f),g=1+i/g,t.abs(g)<f&&(g=f),a*=u=(p=1/p)*g,!(t.abs(u-1)<3e-7));l++);return a},n.gammapinv=function(r,e){var o,i,u,a,f,l,c=0,s=e-1,h=n.gammaln(e);if(r>=1)return t.max(100,e+100*t.sqrt(e));if(r<=0)return 0;for(e>1?(f=t.log(s),l=t.exp(s*(f-1)-h),a=r<.5?r:1-r,o=(2.30753+.27061*(i=t.sqrt(-2*t.log(a))))/(1+i*(.99229+.04481*i))-i,r<.5&&(o=-o),o=t.max(.001,e*t.pow(1-1/(9*e)-o/(3*t.sqrt(e)),3))):o=r<(i=1-e*(.253+.12*e))?t.pow(r/i,1/e):1-t.log(1-(r-i)/(1-i));c<12;c++){if(o<=0)return 0;if((o-=i=(u=(n.lowRegGamma(e,o)-r)/(i=e>1?l*t.exp(-(o-s)+s*(t.log(o)-f)):t.exp(-o+s*t.log(o)-h)))/(1-.5*t.min(1,u*((e-1)/o-1))))<=0&&(o=.5*(o+i)),t.abs(i)<1e-8*o)break}return o},n.erf=function(n){var r,e,o,i,u=[-1.3026537197817094,.6419697923564902,.019476473204185836,-.00956151478680863,-.000946595344482036,.000366839497852761,42523324806907e-18,-20278578112534e-18,-1624290004647e-18,130365583558e-17,1.5626441722e-8,-8.5238095915e-8,6.529054439e-9,5.059343495e-9,-9.91364156e-10,-2.27365122e-10,96467911e-18,2394038e-18,-6886027e-18,894487e-18,313092e-18,-112708e-18,381e-18,7106e-18,-1523e-18,-94e-18,121e-18,-28e-18],a=u.length-1,f=!1,l=0,c=0;for(n<0&&(n=-n,f=!0),e=4*(r=2/(2+n))-2;a>0;a--)o=l,l=e*l-c+u[a],c=o;return i=r*t.exp(-n*n+.5*(u[0]+e*l)-c),f?i-1:1-i},n.erfc=function(t){return 1-n.erf(t)},n.erfcinv=function(r){var e,o,i,u,a=0;if(r>=2)return-100;if(r<=0)return 100;for(u=r<1?r:2-r,e=-.70711*((2.30753+.27061*(i=t.sqrt(-2*t.log(u/2))))/(1+i*(.99229+.04481*i))-i);a<2;a++)e+=(o=n.erfc(e)-u)/(1.1283791670955126*t.exp(-e*e)-e*o);return r<1?e:-e},n.ibetainv=function(r,e,o){var i,u,a,f,l,c,s,h,g,p,m=e-1,d=o-1,v=0;if(r<=0)return 0;if(r>=1)return 1;for(e>=1&&o>=1?(a=r<.5?r:1-r,c=(2.30753+.27061*(f=t.sqrt(-2*t.log(a))))/(1+f*(.99229+.04481*f))-f,r<.5&&(c=-c),s=(c*c-3)/6,h=2/(1/(2*e-1)+1/(2*o-1)),g=c*t.sqrt(s+h)/h-(1/(2*o-1)-1/(2*e-1))*(s+5/6-2/(3*h)),c=e/(e+o*t.exp(2*g))):(i=t.log(e/(e+o)),u=t.log(o/(e+o)),c=r<(f=t.exp(e*i)/e)/(g=f+(l=t.exp(o*u)/o))?t.pow(e*g*r,1/e):1-t.pow(o*g*(1-r),1/o)),p=-n.gammaln(e)-n.gammaln(o)+n.gammaln(e+o);v<10;v++){if(0===c||1===c)return c;if((c-=f=(l=(n.ibeta(c,e,o)-r)/(f=t.exp(m*t.log(c)+d*t.log(1-c)+p)))/(1-.5*t.min(1,l*(m/c-d/(1-c)))))<=0&&(c=.5*(c+f)),c>=1&&(c=.5*(c+f+1)),t.abs(f)<1e-8*c&&v>0)break}return c},n.ibeta=function(r,e,o){var i=0===r||1===r?0:t.exp(n.gammaln(e+o)-n.gammaln(e)-n.gammaln(o)+e*t.log(r)+o*t.log(1-r));return!(r<0||r>1)&&(r<(e+1)/(e+o+2)?i*n.betacf(r,e,o)/e:1-i*n.betacf(1-r,o,e)/o)},n.randn=function(r,e){var o,i,u,a,f;if(e||(e=r),r)return n.create(r,e,(function(){return n.randn()}));do{o=n._random_fn(),i=1.7156*(n._random_fn()-.5),f=(u=o-.449871)*u+(a=t.abs(i)+.386595)*(.196*a-.25472*u)}while(f>.27597&&(f>.27846||i*i>-4*t.log(o)*o*o));return i/o},n.randg=function(r,e,o){var i,u,a,f,l,c,s=r;if(o||(o=e),r||(r=1),e)return(c=n.zeros(e,o)).alter((function(){return n.randg(r)})),c;r<1&&(r+=1),i=r-1/3,u=1/t.sqrt(9*i);do{do{f=1+u*(l=n.randn())}while(f<=0);f*=f*f,a=n._random_fn()}while(a>1-.331*t.pow(l,4)&&t.log(a)>.5*l*l+i*(1-f+t.log(f)));if(r==s)return i*f;do{a=n._random_fn()}while(0===a);return t.pow(a,1/s)*i*f},function(t){for(var r=0;r<t.length;r++)!function(t){n.fn[t]=function(){return n(n.map(this,(function(r){return n[t](r)})))}}(t[r])}("gammaln gammafn factorial factorialln".split(" ")),function(t){for(var r=0;r<t.length;r++)!function(t){n.fn[t]=function(){return n(n[t].apply(null,arguments))}}(t[r])}("randn".split(" "))}(t,Math),function(n,t){function r(n,r,e,o){for(var i,u=0,a=1,f=1,l=1,c=0,s=0;t.abs((f-s)/f)>o;)s=f,a=l+(i=-(r+c)*(r+e+c)*n/(r+2*c)/(r+2*c+1))*a,f=(u=f+i*u)+(i=(c+=1)*(e-c)*n/(r+2*c-1)/(r+2*c))*f,u/=l=a+i*l,a/=l,f/=l,l=1;return f/r}function e(r,e,o){var i=[.9815606342467192,.9041172563704749,.7699026741943047,.5873179542866175,.3678314989981802,.1252334085114689],u=[.04717533638651183,.10693932599531843,.16007832854334622,.20316742672306592,.2334925365383548,.24914704581340277],a=.5*r;if(a>=8)return 1;var f,l=2*n.normal.cdf(a,0,1,1,0)-1;l=l>=t.exp(-50/o)?t.pow(l,o):0;for(var c=a,s=(8-a)/(f=r>3?2:3),h=c+s,g=0,p=o-1,m=1;m<=f;m++){for(var d=0,v=.5*(h+c),E=.5*(h-c),M=1;M<=12;M++){var N,w=v+E*(6<M?i[(N=12-M+1)-1]:-i[(N=M)-1]),y=w*w;if(y>60)break;var I=2*n.normal.cdf(w,0,1,1,0)*.5-2*n.normal.cdf(w,r,1,1,0)*.5;I>=t.exp(-30/p)&&(d+=I=u[N-1]*t.exp(-.5*y)*t.pow(I,p))}g+=d*=2*E*o/t.sqrt(2*t.PI),c=h,h+=s}return(l+=g)<=t.exp(-30/e)?0:(l=t.pow(l,e))>=1?1:l}!function(t){for(var r=0;r<t.length;r++)!function(t){n[t]=function n(t,r,e){return this instanceof n?(this._a=t,this._b=r,this._c=e,this):new n(t,r,e)},n.fn[t]=function(r,e,o){var i=n[t](r,e,o);return i.data=this,i},n[t].prototype.sample=function(r){var e=this._a,o=this._b,i=this._c;return r?n.alter(r,(function(){return n[t].sample(e,o,i)})):n[t].sample(e,o,i)},function(r){for(var e=0;e<r.length;e++)!function(r){n[t].prototype[r]=function(e){var o=this._a,i=this._b,u=this._c;return e||0===e||(e=this.data),"number"!=typeof e?n.fn.map.call(e,(function(e){return n[t][r](e,o,i,u)})):n[t][r](e,o,i,u)}}(r[e])}("pdf cdf inv".split(" ")),function(r){for(var e=0;e<r.length;e++)!function(r){n[t].prototype[r]=function(){return n[t][r](this._a,this._b,this._c)}}(r[e])}("mean median mode variance".split(" "))}(t[r])}("beta centralF cauchy chisquare exponential gamma invgamma kumaraswamy laplace lognormal noncentralt normal pareto studentt weibull uniform binomial negbin hypgeom poisson triangular tukey arcsine".split(" ")),n.extend(n.beta,{pdf:function(r,e,o){return r>1||r<0?0:1==e&&1==o?1:e<512&&o<512?t.pow(r,e-1)*t.pow(1-r,o-1)/n.betafn(e,o):t.exp((e-1)*t.log(r)+(o-1)*t.log(1-r)-n.betaln(e,o))},cdf:function(t,r,e){return t>1||t<0?1*(t>1):n.ibeta(t,r,e)},inv:function(t,r,e){return n.ibetainv(t,r,e)},mean:function(n,t){return n/(n+t)},median:function(t,r){return n.ibetainv(.5,t,r)},mode:function(n,t){return(n-1)/(n+t-2)},sample:function(t,r){var e=n.randg(t);return e/(e+n.randg(r))},variance:function(n,r){return n*r/(t.pow(n+r,2)*(n+r+1))}}),n.extend(n.centralF,{pdf:function(r,e,o){var i;return r<0?0:e<=2?0===r&&e<2?1/0:0===r&&2===e?1:1/n.betafn(e/2,o/2)*t.pow(e/o,e/2)*t.pow(r,e/2-1)*t.pow(1+e/o*r,-(e+o)/2):(i=e*r/(o+r*e),e*(o/(o+r*e))/2*n.binomial.pdf((e-2)/2,(e+o-2)/2,i))},cdf:function(t,r,e){return t<0?0:n.ibeta(r*t/(r*t+e),r/2,e/2)},inv:function(t,r,e){return e/(r*(1/n.ibetainv(t,r/2,e/2)-1))},mean:function(n,t){return t>2?t/(t-2):void 0},mode:function(n,t){return n>2?t*(n-2)/(n*(t+2)):void 0},sample:function(t,r){return 2*n.randg(t/2)/t/(2*n.randg(r/2)/r)},variance:function(n,t){if(!(t<=4))return 2*t*t*(n+t-2)/(n*(t-2)*(t-2)*(t-4))}}),n.extend(n.cauchy,{pdf:function(n,r,e){return e<0?0:e/(t.pow(n-r,2)+t.pow(e,2))/t.PI},cdf:function(n,r,e){return t.atan((n-r)/e)/t.PI+.5},inv:function(n,r,e){return r+e*t.tan(t.PI*(n-.5))},median:function(n){return n},mode:function(n){return n},sample:function(r,e){return n.randn()*t.sqrt(1/(2*n.randg(.5)))*e+r}}),n.extend(n.chisquare,{pdf:function(r,e){return r<0?0:0===r&&2===e?.5:t.exp((e/2-1)*t.log(r)-r/2-e/2*t.log(2)-n.gammaln(e/2))},cdf:function(t,r){return t<0?0:n.lowRegGamma(r/2,t/2)},inv:function(t,r){return 2*n.gammapinv(t,.5*r)},mean:function(n){return n},median:function(n){return n*t.pow(1-2/(9*n),3)},mode:function(n){return n-2>0?n-2:0},sample:function(t){return 2*n.randg(t/2)},variance:function(n){return 2*n}}),n.extend(n.exponential,{pdf:function(n,r){return n<0?0:r*t.exp(-r*n)},cdf:function(n,r){return n<0?0:1-t.exp(-r*n)},inv:function(n,r){return-t.log(1-n)/r},mean:function(n){return 1/n},median:function(n){return 1/n*t.log(2)},mode:function(){return 0},sample:function(r){return-1/r*t.log(n._random_fn())},variance:function(n){return t.pow(n,-2)}}),n.extend(n.gamma,{pdf:function(r,e,o){return r<0?0:0===r&&1===e?1/o:t.exp((e-1)*t.log(r)-r/o-n.gammaln(e)-e*t.log(o))},cdf:function(t,r,e){return t<0?0:n.lowRegGamma(r,t/e)},inv:function(t,r,e){return n.gammapinv(t,r)*e},mean:function(n,t){return n*t},mode:function(n,t){if(n>1)return(n-1)*t},sample:function(t,r){return n.randg(t)*r},variance:function(n,t){return n*t*t}}),n.extend(n.invgamma,{pdf:function(r,e,o){return r<=0?0:t.exp(-(e+1)*t.log(r)-o/r-n.gammaln(e)+e*t.log(o))},cdf:function(t,r,e){return t<=0?0:1-n.lowRegGamma(r,e/t)},inv:function(t,r,e){return e/n.gammapinv(1-t,r)},mean:function(n,t){return n>1?t/(n-1):void 0},mode:function(n,t){return t/(n+1)},sample:function(t,r){return r/n.randg(t)},variance:function(n,t){if(!(n<=2))return t*t/((n-1)*(n-1)*(n-2))}}),n.extend(n.kumaraswamy,{pdf:function(n,r,e){return 0===n&&1===r?e:1===n&&1===e?r:t.exp(t.log(r)+t.log(e)+(r-1)*t.log(n)+(e-1)*t.log(1-t.pow(n,r)))},cdf:function(n,r,e){return n<0?0:n>1?1:1-t.pow(1-t.pow(n,r),e)},inv:function(n,r,e){return t.pow(1-t.pow(1-n,1/e),1/r)},mean:function(t,r){return r*n.gammafn(1+1/t)*n.gammafn(r)/n.gammafn(1+1/t+r)},median:function(n,r){return t.pow(1-t.pow(2,-1/r),1/n)},mode:function(n,r){if(n>=1&&r>=1&&1!==n&&1!==r)return t.pow((n-1)/(n*r-1),1/n)},variance:function(){throw new Error("variance not yet implemented")}}),n.extend(n.lognormal,{pdf:function(n,r,e){return n<=0?0:t.exp(-t.log(n)-.5*t.log(2*t.PI)-t.log(e)-t.pow(t.log(n)-r,2)/(2*e*e))},cdf:function(r,e,o){return r<0?0:.5+.5*n.erf((t.log(r)-e)/t.sqrt(2*o*o))},inv:function(r,e,o){return t.exp(-1.4142135623730951*o*n.erfcinv(2*r)+e)},mean:function(n,r){return t.exp(n+r*r/2)},median:function(n){return t.exp(n)},mode:function(n,r){return t.exp(n-r*r)},sample:function(r,e){return t.exp(n.randn()*e+r)},variance:function(n,r){return(t.exp(r*r)-1)*t.exp(2*n+r*r)}}),n.extend(n.noncentralt,{pdf:function(r,e,o){return t.abs(o)<1e-14?n.studentt.pdf(r,e):t.abs(r)<1e-14?t.exp(n.gammaln((e+1)/2)-o*o/2-.5*t.log(t.PI*e)-n.gammaln(e/2)):e/r*(n.noncentralt.cdf(r*t.sqrt(1+2/e),e+2,o)-n.noncentralt.cdf(r,e,o))},cdf:function(r,e,o){var i=1e-14;if(t.abs(o)<i)return n.studentt.cdf(r,e);var u=!1;r<0&&(u=!0,o=-o);for(var a=n.normal.cdf(-o,0,1),f=i+1,l=f,c=r*r/(r*r+e),s=0,h=t.exp(-o*o/2),g=t.exp(-o*o/2-.5*t.log(2)-n.gammaln(1.5))*o;s<200||l>i||f>i;)l=f,s>0&&(h*=o*o/(2*s),g*=o*o/(2*(s+.5))),a+=.5*(f=h*n.beta.cdf(c,s+.5,e/2)+g*n.beta.cdf(c,s+1,e/2)),s++;return u?1-a:a}}),n.extend(n.normal,{pdf:function(n,r,e){return t.exp(-.5*t.log(2*t.PI)-t.log(e)-t.pow(n-r,2)/(2*e*e))},cdf:function(r,e,o){return.5*(1+n.erf((r-e)/t.sqrt(2*o*o)))},inv:function(t,r,e){return-1.4142135623730951*e*n.erfcinv(2*t)+r},mean:function(n){return n},median:function(n){return n},mode:function(n){return n},sample:function(t,r){return n.randn()*r+t},variance:function(n,t){return t*t}}),n.extend(n.pareto,{pdf:function(n,r,e){return n<r?0:e*t.pow(r,e)/t.pow(n,e+1)},cdf:function(n,r,e){return n<r?0:1-t.pow(r/n,e)},inv:function(n,r,e){return r/t.pow(1-n,1/e)},mean:function(n,r){if(!(r<=1))return r*t.pow(n,r)/(r-1)},median:function(n,r){return n*(r*t.SQRT2)},mode:function(n){return n},variance:function(n,r){if(!(r<=2))return n*n*r/(t.pow(r-1,2)*(r-2))}}),n.extend(n.studentt,{pdf:function(r,e){return e=e>1e100?1e100:e,1/(t.sqrt(e)*n.betafn(.5,e/2))*t.pow(1+r*r/e,-(e+1)/2)},cdf:function(r,e){var o=e/2;return n.ibeta((r+t.sqrt(r*r+e))/(2*t.sqrt(r*r+e)),o,o)},inv:function(r,e){var o=n.ibetainv(2*t.min(r,1-r),.5*e,.5);return o=t.sqrt(e*(1-o)/o),r>.5?o:-o},mean:function(n){return n>1?0:void 0},median:function(){return 0},mode:function(){return 0},sample:function(r){return n.randn()*t.sqrt(r/(2*n.randg(r/2)))},variance:function(n){return n>2?n/(n-2):n>1?1/0:void 0}}),n.extend(n.weibull,{pdf:function(n,r,e){return n<0||r<0||e<0?0:e/r*t.pow(n/r,e-1)*t.exp(-t.pow(n/r,e))},cdf:function(n,r,e){return n<0?0:1-t.exp(-t.pow(n/r,e))},inv:function(n,r,e){return r*t.pow(-t.log(1-n),1/e)},mean:function(t,r){return t*n.gammafn(1+1/r)},median:function(n,r){return n*t.pow(t.log(2),1/r)},mode:function(n,r){return r<=1?0:n*t.pow((r-1)/r,1/r)},sample:function(r,e){return r*t.pow(-t.log(n._random_fn()),1/e)},variance:function(r,e){return r*r*n.gammafn(1+2/e)-t.pow(n.weibull.mean(r,e),2)}}),n.extend(n.uniform,{pdf:function(n,t,r){return n<t||n>r?0:1/(r-t)},cdf:function(n,t,r){return n<t?0:n<r?(n-t)/(r-t):1},inv:function(n,t,r){return t+n*(r-t)},mean:function(n,t){return.5*(n+t)},median:function(t,r){return n.mean(t,r)},mode:function(){throw new Error("mode is not yet implemented")},sample:function(t,r){return t/2+r/2+(r/2-t/2)*(2*n._random_fn()-1)},variance:function(n,r){return t.pow(r-n,2)/12}}),n.extend(n.binomial,{pdf:function(r,e,o){return 0===o||1===o?e*o===r?1:0:n.combination(e,r)*t.pow(o,r)*t.pow(1-o,e-r)},cdf:function(e,o,i){var u,a=1e-10;if(e<0)return 0;if(e>=o)return 1;if(i<0||i>1||o<=0)return NaN;var f=i,l=(e=t.floor(e))+1,c=o-e,s=l+c,h=t.exp(n.gammaln(s)-n.gammaln(c)-n.gammaln(l)+l*t.log(f)+c*t.log(1-f));return u=f<(l+1)/(s+2)?h*r(f,l,c,a):1-h*r(1-f,c,l,a),t.round(1/a*(1-u))/(1/a)}}),n.extend(n.negbin,{pdf:function(r,e,o){return r===r>>>0&&(r<0?0:n.combination(r+e-1,e-1)*t.pow(1-o,r)*t.pow(o,e))},cdf:function(t,r,e){var o=0,i=0;if(t<0)return 0;for(;i<=t;i++)o+=n.negbin.pdf(i,r,e);return o}}),n.extend(n.hypgeom,{pdf:function(r,e,o,i){if(r!=r|0)return!1;if(r<0||r<o-(e-i))return 0;if(r>i||r>o)return 0;if(2*o>e)return 2*i>e?n.hypgeom.pdf(e-o-i+r,e,e-o,e-i):n.hypgeom.pdf(i-r,e,e-o,i);if(2*i>e)return n.hypgeom.pdf(o-r,e,o,e-i);if(o<i)return n.hypgeom.pdf(r,e,i,o);for(var u=1,a=0,f=0;f<r;f++){for(;u>1&&a<i;)u*=1-o/(e-a),a++;u*=(i-f)*(o-f)/((f+1)*(e-o-i+f+1))}for(;a<i;a++)u*=1-o/(e-a);return t.min(1,t.max(0,u))},cdf:function(r,e,o,i){if(r<0||r<o-(e-i))return 0;if(r>=i||r>=o)return 1;if(2*o>e)return 2*i>e?n.hypgeom.cdf(e-o-i+r,e,e-o,e-i):1-n.hypgeom.cdf(i-r-1,e,e-o,i);if(2*i>e)return 1-n.hypgeom.cdf(o-r-1,e,o,e-i);if(o<i)return n.hypgeom.cdf(r,e,i,o);for(var u=1,a=1,f=0,l=0;l<r;l++){for(;u>1&&f<i;){var c=1-o/(e-f);a*=c,u*=c,f++}u+=a*=(i-l)*(o-l)/((l+1)*(e-o-i+l+1))}for(;f<i;f++)u*=1-o/(e-f);return t.min(1,t.max(0,u))}}),n.extend(n.poisson,{pdf:function(r,e){return e<0||r%1!=0||r<0?0:t.pow(e,r)*t.exp(-e)/n.factorial(r)},cdf:function(t,r){var e=[],o=0;if(t<0)return 0;for(;o<=t;o++)e.push(n.poisson.pdf(o,r));return n.sum(e)},mean:function(n){return n},variance:function(n){return n},sampleSmall:function(r){var e=1,o=0,i=t.exp(-r);do{o++,e*=n._random_fn()}while(e>i);return o-1},sampleLarge:function(r){var e,o,i,u,a,f,l,c,s,h,g=r;for(u=t.sqrt(g),a=t.log(g),f=.02483*(l=.931+2.53*u)-.059,c=1.1239+1.1328/(l-3.4),s=.9277-3.6224/(l-2);;){if(o=t.random()-.5,i=t.random(),h=.5-t.abs(o),e=t.floor((2*f/h+l)*o+g+.43),h>=.07&&i<=s)return e;if(!(e<0||h<.013&&i>h)&&t.log(i)+t.log(c)-t.log(f/(h*h)+l)<=e*a-g-n.loggam(e+1))return e}},sample:function(n){return n<10?this.sampleSmall(n):this.sampleLarge(n)}}),n.extend(n.triangular,{pdf:function(n,t,r,e){return r<=t||e<t||e>r?NaN:n<t||n>r?0:n<e?2*(n-t)/((r-t)*(e-t)):n===e?2/(r-t):2*(r-n)/((r-t)*(r-e))},cdf:function(n,r,e,o){return e<=r||o<r||o>e?NaN:n<=r?0:n>=e?1:n<=o?t.pow(n-r,2)/((e-r)*(o-r)):1-t.pow(e-n,2)/((e-r)*(e-o))},inv:function(n,r,e,o){return e<=r||o<r||o>e?NaN:n<=(o-r)/(e-r)?r+(e-r)*t.sqrt(n*((o-r)/(e-r))):r+(e-r)*(1-t.sqrt((1-n)*(1-(o-r)/(e-r))))},mean:function(n,t,r){return(n+t+r)/3},median:function(n,r,e){return e<=(n+r)/2?r-t.sqrt((r-n)*(r-e))/t.sqrt(2):e>(n+r)/2?n+t.sqrt((r-n)*(e-n))/t.sqrt(2):void 0},mode:function(n,t,r){return r},sample:function(r,e,o){var i=n._random_fn();return i<(o-r)/(e-r)?r+t.sqrt(i*(e-r)*(o-r)):e-t.sqrt((1-i)*(e-r)*(e-o))},variance:function(n,t,r){return(n*n+t*t+r*r-n*t-n*r-t*r)/18}}),n.extend(n.arcsine,{pdf:function(n,r,e){return e<=r?NaN:n<=r||n>=e?0:2/t.PI*t.pow(t.pow(e-r,2)-t.pow(2*n-r-e,2),-.5)},cdf:function(n,r,e){return n<r?0:n<e?2/t.PI*t.asin(t.sqrt((n-r)/(e-r))):1},inv:function(n,r,e){return r+(.5-.5*t.cos(t.PI*n))*(e-r)},mean:function(n,t){return t<=n?NaN:(n+t)/2},median:function(n,t){return t<=n?NaN:(n+t)/2},mode:function(){throw new Error("mode is not yet implemented")},sample:function(r,e){return(r+e)/2+(e-r)/2*t.sin(2*t.PI*n.uniform.sample(0,1))},variance:function(n,r){return r<=n?NaN:t.pow(r-n,2)/8}}),n.extend(n.laplace,{pdf:function(n,r,e){return e<=0?0:t.exp(-t.abs(n-r)/e)/(2*e)},cdf:function(n,r,e){return e<=0?0:n<r?.5*t.exp((n-r)/e):1-.5*t.exp(-(n-r)/e)},mean:function(n){return n},median:function(n){return n},mode:function(n){return n},variance:function(n,t){return 2*t*t},sample:function(r,e){var o,i=n._random_fn()-.5;return r-e*((o=i)/t.abs(o))*t.log(1-2*t.abs(i))}}),n.extend(n.tukey,{cdf:function(r,o,i){var u=o,a=[.9894009349916499,.9445750230732326,.8656312023878318,.755404408355003,.6178762444026438,.45801677765722737,.2816035507792589,.09501250983763744],f=[.027152459411754096,.062253523938647894,.09515851168249279,.12462897125553388,.14959598881657674,.16915651939500254,.18260341504492358,.1894506104550685];if(r<=0)return 0;if(i<2||u<2)return NaN;if(!Number.isFinite(r))return 1;if(i>25e3)return e(r,1,u);var l,c=.5*i,s=c*t.log(i)-i*t.log(2)-n.gammaln(c),h=c-1,g=.25*i;l=i<=100?1:i<=800?.5:i<=5e3?.25:.125,s+=t.log(l);for(var p=0,m=1;m<=50;m++){for(var d=0,v=(2*m-1)*l,E=1;E<=16;E++){var M,N;8<E?(M=E-8-1,N=s+h*t.log(v+a[M]*l)-(a[M]*l+v)*g):(M=E-1,N=s+h*t.log(v-a[M]*l)+(a[M]*l-v)*g),N>=-30&&(d+=e(8<E?r*t.sqrt(.5*(a[M]*l+v)):r*t.sqrt(.5*(-a[M]*l+v)),1,u)*f[M]*t.exp(N))}if(m*l>=1&&d<=1e-14)break;p+=d}if(d>1e-14)throw new Error("tukey.cdf failed to converge");return p>1&&(p=1),p},inv:function(r,e,o){if(o<2||e<2)return NaN;if(r<0||r>1)return NaN;if(0===r)return 0;if(1===r)return 1/0;var i,u=function(n,r,e){var o=.5-.5*n,i=t.sqrt(t.log(1/(o*o))),u=i+((((-453642210148e-16*i-.204231210125)*i-.342242088547)*i-1)*i+.322232421088)/((((.0038560700634*i+.10353775285)*i+.531103462366)*i+.588581570495)*i+.099348462606);e<120&&(u+=(u*u*u+u)/e/4);var a=.8832-.2368*u;return e<120&&(a+=-1.214/e+1.208*u/e),u*(a*t.log(r-1)+1.4142)}(r,e,o),a=n.tukey.cdf(u,e,o)-r;i=a>0?t.max(0,u-1):u+1;for(var f,l=n.tukey.cdf(i,e,o)-r,c=1;c<50;c++)if(f=i-l*(i-u)/(l-a),a=l,u=i,f<0&&(f=0,l=-r),l=n.tukey.cdf(f,e,o)-r,i=f,t.abs(i-u)<1e-4)return f;throw new Error("tukey.inv failed to converge")}})}(t,Math),function(n,t){var r,e,o=Array.prototype.push,i=n.utils.isArray;function u(t){return i(t)||t instanceof n}n.extend({add:function(t,r){return u(r)?(u(r[0])||(r=[r]),n.map(t,(function(n,t,e){return n+r[t][e]}))):n.map(t,(function(n){return n+r}))},subtract:function(t,r){return u(r)?(u(r[0])||(r=[r]),n.map(t,(function(n,t,e){return n-r[t][e]||0}))):n.map(t,(function(n){return n-r}))},divide:function(t,r){return u(r)?(u(r[0])||(r=[r]),n.multiply(t,n.inv(r))):n.map(t,(function(n){return n/r}))},multiply:function(t,r){var e,o,i,a,f,l,c,s;if(void 0===t.length&&void 0===r.length)return t*r;if(f=t.length,l=t[0].length,c=n.zeros(f,i=u(r)?r[0].length:l),s=0,u(r)){for(;s<i;s++)for(e=0;e<f;e++){for(a=0,o=0;o<l;o++)a+=t[e][o]*r[o][s];c[e][s]=a}return 1===f&&1===s?c[0][0]:c}return n.map(t,(function(n){return n*r}))},outer:function(t,r){return n.multiply(t.map((function(n){return[n]})),[r])},dot:function(t,r){u(t[0])||(t=[t]),u(r[0])||(r=[r]);for(var e,o,i=1===t[0].length&&1!==t.length?n.transpose(t):t,a=1===r[0].length&&1!==r.length?n.transpose(r):r,f=[],l=0,c=i.length,s=i[0].length;l<c;l++){for(f[l]=[],e=0,o=0;o<s;o++)e+=i[l][o]*a[l][o];f[l]=e}return 1===f.length?f[0]:f},pow:function(r,e){return n.map(r,(function(n){return t.pow(n,e)}))},exp:function(r){return n.map(r,(function(n){return t.exp(n)}))},log:function(r){return n.map(r,(function(n){return t.log(n)}))},abs:function(r){return n.map(r,(function(n){return t.abs(n)}))},norm:function(n,r){var e=0,o=0;for(isNaN(r)&&(r=2),u(n[0])&&(n=n[0]);o<n.length;o++)e+=t.pow(t.abs(n[o]),r);return t.pow(e,1/r)},angle:function(r,e){return t.acos(n.dot(r,e)/(n.norm(r)*n.norm(e)))},aug:function(n,t){var r,e=[];for(r=0;r<n.length;r++)e.push(n[r].slice());for(r=0;r<e.length;r++)o.apply(e[r],t[r]);return e},inv:function(t){for(var r,e=t.length,o=t[0].length,i=n.identity(e,o),u=n.gauss_jordan(t,i),a=[],f=0;f<e;f++)for(a[f]=[],r=o;r<u[0].length;r++)a[f][r-o]=u[f][r];return a},det:function n(t){if(2===t.length)return t[0][0]*t[1][1]-t[0][1]*t[1][0];for(var r=0,e=0;e<t.length;e++){for(var o=[],i=1;i<t.length;i++){o[i-1]=[];for(var u=0;u<t.length;u++)u<e?o[i-1][u]=t[i][u]:u>e&&(o[i-1][u-1]=t[i][u])}var a=e%2?-1:1;r+=n(o)*t[0][e]*a}return r},gauss_elimination:function(r,e){var o,i,u,a,f=0,l=0,c=r.length,s=r[0].length,h=1,g=0,p=[];for(o=(r=n.aug(r,e))[0].length,f=0;f<c;f++){for(i=r[f][f],l=f,a=f+1;a<s;a++)i<t.abs(r[a][f])&&(i=r[a][f],l=a);if(l!=f)for(a=0;a<o;a++)u=r[f][a],r[f][a]=r[l][a],r[l][a]=u;for(l=f+1;l<c;l++)for(h=r[l][f]/r[f][f],a=f;a<o;a++)r[l][a]=r[l][a]-h*r[f][a]}for(f=c-1;f>=0;f--){for(g=0,l=f+1;l<=c-1;l++)g+=p[l]*r[f][l];p[f]=(r[f][o-1]-g)/r[f][f]}return p},gauss_jordan:function(r,e){var o,i,u,a=n.aug(r,e),f=a.length,l=a[0].length,c=0;for(i=0;i<f;i++){var s=i;for(u=i+1;u<f;u++)t.abs(a[u][i])>t.abs(a[s][i])&&(s=u);var h=a[i];for(a[i]=a[s],a[s]=h,u=i+1;u<f;u++)for(c=a[u][i]/a[i][i],o=i;o<l;o++)a[u][o]-=a[i][o]*c}for(i=f-1;i>=0;i--){for(c=a[i][i],u=0;u<i;u++)for(o=l-1;o>i-1;o--)a[u][o]-=a[i][o]*a[u][i]/c;for(a[i][i]/=c,o=f;o<l;o++)a[i][o]/=c}return a},triaUpSolve:function(t,r){var e,o=t[0].length,i=n.zeros(1,o)[0],u=!1;return null!=r[0].length&&(r=r.map((function(n){return n[0]})),u=!0),n.arange(o-1,-1,-1).forEach((function(u){e=n.arange(u+1,o).map((function(n){return i[n]*t[u][n]})),i[u]=(r[u]-n.sum(e))/t[u][u]})),u?i.map((function(n){return[n]})):i},triaLowSolve:function(t,r){var e,o=t[0].length,i=n.zeros(1,o)[0],u=!1;return null!=r[0].length&&(r=r.map((function(n){return n[0]})),u=!0),n.arange(o).forEach((function(o){e=n.arange(o).map((function(n){return t[o][n]*i[n]})),i[o]=(r[o]-n.sum(e))/t[o][o]})),u?i.map((function(n){return[n]})):i},lu:function(t){var r,e=t.length,o=n.identity(e),i=n.zeros(t.length,t[0].length);return n.arange(e).forEach((function(n){i[0][n]=t[0][n]})),n.arange(1,e).forEach((function(u){n.arange(u).forEach((function(e){r=n.arange(e).map((function(n){return o[u][n]*i[n][e]})),o[u][e]=(t[u][e]-n.sum(r))/i[e][e]})),n.arange(u,e).forEach((function(e){r=n.arange(u).map((function(n){return o[u][n]*i[n][e]})),i[u][e]=t[r.length][e]-n.sum(r)}))})),[o,i]},cholesky:function(r){var e,o=r.length,i=n.zeros(r.length,r[0].length);return n.arange(o).forEach((function(u){e=n.arange(u).map((function(n){return t.pow(i[u][n],2)})),i[u][u]=t.sqrt(r[u][u]-n.sum(e)),n.arange(u+1,o).forEach((function(t){e=n.arange(u).map((function(n){return i[u][n]*i[t][n]})),i[t][u]=(r[u][t]-n.sum(e))/i[u][u]}))})),i},gauss_jacobi:function(r,e,o,i){for(var u,a,f,l,c=0,s=0,h=r.length,g=[],p=[],m=[];c<h;c++)for(g[c]=[],p[c]=[],m[c]=[],s=0;s<h;s++)c>s?(g[c][s]=r[c][s],p[c][s]=m[c][s]=0):c<s?(p[c][s]=r[c][s],g[c][s]=m[c][s]=0):(m[c][s]=r[c][s],g[c][s]=p[c][s]=0);for(f=n.multiply(n.multiply(n.inv(m),n.add(g,p)),-1),a=n.multiply(n.inv(m),e),u=o,l=n.add(n.multiply(f,o),a),c=2;t.abs(n.norm(n.subtract(l,u)))>i;)u=l,l=n.add(n.multiply(f,u),a),c++;return l},gauss_seidel:function(r,e,o,i){for(var u,a,f,l,c,s=0,h=r.length,g=[],p=[],m=[];s<h;s++)for(g[s]=[],p[s]=[],m[s]=[],u=0;u<h;u++)s>u?(g[s][u]=r[s][u],p[s][u]=m[s][u]=0):s<u?(p[s][u]=r[s][u],g[s][u]=m[s][u]=0):(m[s][u]=r[s][u],g[s][u]=p[s][u]=0);for(l=n.multiply(n.multiply(n.inv(n.add(m,g)),p),-1),f=n.multiply(n.inv(n.add(m,g)),e),a=o,c=n.add(n.multiply(l,o),f),s=2;t.abs(n.norm(n.subtract(c,a)))>i;)a=c,c=n.add(n.multiply(l,a),f),s+=1;return c},SOR:function(r,e,o,i,u){for(var a,f,l,c,s,h=0,g=r.length,p=[],m=[],d=[];h<g;h++)for(p[h]=[],m[h]=[],d[h]=[],a=0;a<g;a++)h>a?(p[h][a]=r[h][a],m[h][a]=d[h][a]=0):h<a?(m[h][a]=r[h][a],p[h][a]=d[h][a]=0):(d[h][a]=r[h][a],p[h][a]=m[h][a]=0);for(c=n.multiply(n.inv(n.add(d,n.multiply(p,u))),n.subtract(n.multiply(d,1-u),n.multiply(m,u))),l=n.multiply(n.multiply(n.inv(n.add(d,n.multiply(p,u))),e),u),f=o,s=n.add(n.multiply(c,o),l),h=2;t.abs(n.norm(n.subtract(s,f)))>i;)f=s,s=n.add(n.multiply(c,f),l),h++;return s},householder:function(r){for(var e,o,i,u,a=r.length,f=r[0].length,l=0,c=[],s=[];l<a-1;l++){for(e=0,u=l+1;u<f;u++)e+=r[u][l]*r[u][l];for(e=(r[l+1][l]>0?-1:1)*t.sqrt(e),o=t.sqrt((e*e-r[l+1][l]*e)/2),(c=n.zeros(a,1))[l+1][0]=(r[l+1][l]-e)/(2*o),i=l+2;i<a;i++)c[i][0]=r[i][l]/(2*o);s=n.subtract(n.identity(a,f),n.multiply(n.multiply(c,n.transpose(c)),2)),r=n.multiply(s,n.multiply(r,s))}return r},QR:(r=n.sum,e=n.arange,function(o){var i,u,a,f=o.length,l=o[0].length,c=n.zeros(l,l);for(o=n.copy(o),u=0;u<l;u++){for(c[u][u]=t.sqrt(r(e(f).map((function(n){return o[n][u]*o[n][u]})))),i=0;i<f;i++)o[i][u]=o[i][u]/c[u][u];for(a=u+1;a<l;a++)for(c[u][a]=r(e(f).map((function(n){return o[n][u]*o[n][a]}))),i=0;i<f;i++)o[i][a]=o[i][a]-o[i][u]*c[u][a]}return[o,c]}),lstsq:function(t,r){var e=!1;void 0===r[0].length&&(r=r.map((function(n){return[n]})),e=!0);var o=n.QR(t),i=o[0],u=o[1],a=t[0].length,f=n.slice(i,{col:{end:a}}),l=function(t){var r=(t=n.copy(t)).length,e=n.identity(r);return n.arange(r-1,-1,-1).forEach((function(r){n.sliceAssign(e,{row:r},n.divide(n.slice(e,{row:r}),t[r][r])),n.sliceAssign(t,{row:r},n.divide(n.slice(t,{row:r}),t[r][r])),n.arange(r).forEach((function(o){var i=n.multiply(t[o][r],-1),u=n.slice(t,{row:o}),a=n.multiply(n.slice(t,{row:r}),i);n.sliceAssign(t,{row:o},n.add(u,a));var f=n.slice(e,{row:o}),l=n.multiply(n.slice(e,{row:r}),i);n.sliceAssign(e,{row:o},n.add(f,l))}))})),e}(n.slice(u,{row:{end:a}})),c=n.transpose(f);void 0===c[0].length&&(c=[c]);var s=n.multiply(n.multiply(l,c),r);return void 0===s.length&&(s=[[s]]),e?s.map((function(n){return n[0]})):s},jacobi:function(r){for(var e,o,i,u,a,f,l,c=1,s=r.length,h=n.identity(s,s),g=[];1===c;){for(a=r[0][1],i=0,u=1,e=0;e<s;e++)for(o=0;o<s;o++)e!=o&&a<t.abs(r[e][o])&&(a=t.abs(r[e][o]),i=e,u=o);for(f=r[i][i]===r[u][u]?r[i][u]>0?t.PI/4:-t.PI/4:t.atan(2*r[i][u]/(r[i][i]-r[u][u]))/2,(l=n.identity(s,s))[i][i]=t.cos(f),l[i][u]=-t.sin(f),l[u][i]=t.sin(f),l[u][u]=t.cos(f),h=n.multiply(h,l),r=n.multiply(n.multiply(n.inv(l),r),l),c=0,e=1;e<s;e++)for(o=1;o<s;o++)e!=o&&t.abs(r[e][o])>.001&&(c=1)}for(e=0;e<s;e++)g.push(r[e][e]);return[h,g]},rungekutta:function(n,t,r,e,o,i){var u,a,f;if(2===i)for(;e<=r;)o+=((u=t*n(e,o))+(a=t*n(e+t,o+u)))/2,e+=t;if(4===i)for(;e<=r;)o+=((u=t*n(e,o))+2*(a=t*n(e+t/2,o+u/2))+2*(f=t*n(e+t/2,o+a/2))+t*n(e+t,o+f))/6,e+=t;return o},romberg:function(n,r,e,o){for(var i,u,a,f,l,c=0,s=(e-r)/2,h=[],g=[],p=[];c<o/2;){for(l=n(r),a=r,f=0;a<=e;a+=s,f++)h[f]=a;for(i=h.length,a=1;a<i-1;a++)l+=(a%2!=0?4:2)*n(h[a]);l=s/3*(l+n(e)),p[c]=l,s/=2,c++}for(u=p.length,i=1;1!==u;){for(a=0;a<u-1;a++)g[a]=(t.pow(4,i)*p[a+1]-p[a])/(t.pow(4,i)-1);u=g.length,p=g,g=[],i++}return p},richardson:function(n,r,e,o){function i(n,t){for(var r,e=0,o=n.length;e<o;e++)n[e]===t&&(r=e);return r}for(var u,a,f,l,c,s=t.abs(e-n[i(n,e)+1]),h=0,g=[],p=[];o>=s;)u=i(n,e+o),a=i(n,e),g[h]=(r[u]-2*r[a]+r[2*a-u])/(o*o),o/=2,h++;for(l=g.length,f=1;1!=l;){for(c=0;c<l-1;c++)p[c]=(t.pow(4,f)*g[c+1]-g[c])/(t.pow(4,f)-1);l=p.length,g=p,p=[],f++}return g},simpson:function(n,t,r,e){for(var o,i=(r-t)/e,u=n(t),a=[],f=t,l=0,c=1;f<=r;f+=i,l++)a[l]=f;for(o=a.length;c<o-1;c++)u+=(c%2!=0?4:2)*n(a[c]);return i/3*(u+n(r))},hermite:function(n,t,r,e){for(var o,i=n.length,u=0,a=0,f=[],l=[],c=[],s=[];a<i;a++){for(f[a]=1,o=0;o<i;o++)a!=o&&(f[a]*=(e-n[o])/(n[a]-n[o]));for(l[a]=0,o=0;o<i;o++)a!=o&&(l[a]+=1/(n[a]-n[o]));c[a]=(1-2*(e-n[a])*l[a])*(f[a]*f[a]),s[a]=(e-n[a])*(f[a]*f[a]),u+=c[a]*t[a]+s[a]*r[a]}return u},lagrange:function(n,t,r){for(var e,o,i=0,u=0,a=n.length;u<a;u++){for(o=t[u],e=0;e<a;e++)u!=e&&(o*=(r-n[e])/(n[u]-n[e]));i+=o}return i},cubic_spline:function(t,r,e){for(var o,i,u=t.length,a=0,f=[],l=[],c=[],s=[],h=[],g=[];a<u-1;a++)s[a]=t[a+1]-t[a];for(c[0]=0,a=1;a<u-1;a++)c[a]=3/s[a]*(r[a+1]-r[a])-3/s[a-1]*(r[a]-r[a-1]);for(a=1;a<u-1;a++)f[a]=[],l[a]=[],f[a][a-1]=s[a-1],f[a][a]=2*(s[a-1]+s[a]),f[a][a+1]=s[a],l[a][0]=c[a];for(i=n.multiply(n.inv(f),l),o=0;o<u-1;o++)h[o]=(r[o+1]-r[o])/s[o]-s[o]*(i[o+1][0]+2*i[o][0])/3,g[o]=(i[o+1][0]-i[o][0])/(3*s[o]);for(o=0;o<u&&!(t[o]>e);o++);return r[o-=1]+(e-t[o])*h[o]+n.sq(e-t[o])*i[o]+(e-t[o])*n.sq(e-t[o])*g[o]},gauss_quadrature:function(){throw new Error("gauss_quadrature not yet implemented")},PCA:function(t){var r,e,o,i,u,a=t.length,f=t[0].length,l=0,c=[],s=[],h=[],g=[],p=[],m=[],d=[];for(l=0;l<a;l++)c[l]=n.sum(t[l])/f;for(l=0;l<f;l++)for(p[l]=[],r=0;r<a;r++)p[l][r]=t[r][l]-c[r];for(p=n.transpose(p),l=0;l<a;l++)for(m[l]=[],r=0;r<a;r++)m[l][r]=n.dot([p[l]],[p[r]])/(f-1);for(u=(o=n.jacobi(m))[0],s=o[1],d=n.transpose(u),l=0;l<s.length;l++)for(r=l;r<s.length;r++)s[l]<s[r]&&(e=s[l],s[l]=s[r],s[r]=e,h=d[l],d[l]=d[r],d[r]=h);for(i=n.transpose(p),l=0;l<a;l++)for(g[l]=[],r=0;r<i.length;r++)g[l][r]=n.dot([d[l]],[i[r]]);return[t,s,d,g]}}),function(t){for(var r=0;r<t.length;r++)!function(t){n.fn[t]=function(r,e){var o=this;return e?(setTimeout((function(){e.call(o,n.fn[t].call(o,r))}),15),this):"number"==typeof n[t](this,r)?n[t](this,r):n(n[t](this,r))}}(t[r])}("add divide multiply subtract dot pow exp log abs norm angle".split(" "))}(t,Math),function(n,t){var r=[].slice,e=n.utils.isNumber,o=n.utils.isArray;function i(n,r,e,o){if(n>1||e>1||n<=0||e<=0)throw new Error("Proportions should be greater than 0 and less than 1");var i=(n*r+e*o)/(r+o);return(n-e)/t.sqrt(i*(1-i)*(1/r+1/o))}n.extend({zscore:function(){var t=r.call(arguments);return e(t[1])?(t[0]-t[1])/t[2]:(t[0]-n.mean(t[1]))/n.stdev(t[1],t[2])},ztest:function(){var e,i=r.call(arguments);return o(i[1])?(e=n.zscore(i[0],i[1],i[3]),1===i[2]?n.normal.cdf(-t.abs(e),0,1):2*n.normal.cdf(-t.abs(e),0,1)):i.length>2?(e=n.zscore(i[0],i[1],i[2]),1===i[3]?n.normal.cdf(-t.abs(e),0,1):2*n.normal.cdf(-t.abs(e),0,1)):(e=i[0],1===i[1]?n.normal.cdf(-t.abs(e),0,1):2*n.normal.cdf(-t.abs(e),0,1))}}),n.extend(n.fn,{zscore:function(n,t){return(n-this.mean())/this.stdev(t)},ztest:function(r,e,o){var i=t.abs(this.zscore(r,o));return 1===e?n.normal.cdf(-i,0,1):2*n.normal.cdf(-i,0,1)}}),n.extend({tscore:function(){var e=r.call(arguments);return 4===e.length?(e[0]-e[1])/(e[2]/t.sqrt(e[3])):(e[0]-n.mean(e[1]))/(n.stdev(e[1],!0)/t.sqrt(e[1].length))},ttest:function(){var o,i=r.call(arguments);return 5===i.length?(o=t.abs(n.tscore(i[0],i[1],i[2],i[3])),1===i[4]?n.studentt.cdf(-o,i[3]-1):2*n.studentt.cdf(-o,i[3]-1)):e(i[1])?(o=t.abs(i[0]),1==i[2]?n.studentt.cdf(-o,i[1]-1):2*n.studentt.cdf(-o,i[1]-1)):(o=t.abs(n.tscore(i[0],i[1])),1==i[2]?n.studentt.cdf(-o,i[1].length-1):2*n.studentt.cdf(-o,i[1].length-1))}}),n.extend(n.fn,{tscore:function(n){return(n-this.mean())/(this.stdev(!0)/t.sqrt(this.cols()))},ttest:function(r,e){return 1===e?1-n.studentt.cdf(t.abs(this.tscore(r)),this.cols()-1):2*n.studentt.cdf(-t.abs(this.tscore(r)),this.cols()-1)}}),n.extend({anovafscore:function(){var e,o,i,u,a,f,l,c,s=r.call(arguments);if(1===s.length){for(a=new Array(s[0].length),l=0;l<s[0].length;l++)a[l]=s[0][l];s=a}for(o=new Array,l=0;l<s.length;l++)o=o.concat(s[l]);for(i=n.mean(o),e=0,l=0;l<s.length;l++)e+=s[l].length*t.pow(n.mean(s[l])-i,2);for(e/=s.length-1,f=0,l=0;l<s.length;l++)for(u=n.mean(s[l]),c=0;c<s[l].length;c++)f+=t.pow(s[l][c]-u,2);return e/(f/(o.length-s.length))},anovaftest:function(){var t,o,i,u,a=r.call(arguments);if(e(a[0]))return 1-n.centralF.cdf(a[0],a[1],a[2])