-
Notifications
You must be signed in to change notification settings - Fork 3
/
mctad.min.js
2 lines (2 loc) · 25.8 KB
/
mctad.min.js
1
2
/*! mctad 2014-07-25 */
mctad={version:"0.0.1"},mctad.π=Math.PI,mctad.ε=1e-4,mctad.isInteger=function(a){return/^-?\d+$/.test(a)},mctad.allPositive=function(a){for(var b=!0,c=0;c<a.length;c++)if(a[c]<0){b=!1;break}return b},mctad.sign=function(a){return isNaN(a)?0/0:0===a?a:a>0?1:-1},mctad.extend=function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c]);return a},mctad.sortNumeric=function(a){return"undefined"==typeof a?void 0:(a.sort(function(a,b){return a-b}),a)},mctad.toRadians=function(a){return"string"==typeof a||a instanceof String?"°"===a.trim().slice(-1)?Math.PI/180*parseFloat(a):parseFloat(a):a},mctad.getBaseLog=function(a,b){return Math.log(b)/Math.log(a)},mctad.getRandomArbitrary=function(a,b){return Math.random()*(b-a)+a},mctad.getRandomInt=function(a,b){return Math.floor(Math.random()*(b-a+1))+a},mctad.factorial=function(a){if(!mctad.isInteger(a)||0>a)return void 0;for(var b=1,c=2;a>=c;c++)b*=c;return b},mctad.doubleFactorial=function(a){if(!mctad.isInteger(a)||a%2===0)return void 0;var b;return a>0?b=a>1?a*mctad.doubleFactorial(a-2):1:(0>a&&(b=-1>a?mctad.doubleFactorial(a+2)/(a+2):1),b)},mctad.Γ=function(a){if(!mctad.isInteger(2*a))return void 0;if(0>=a&&mctad.isInteger(a))return 1/0;var b;return mctad.isInteger(a)?b=mctad.factorial(a-1):mctad.isInteger(2*a)&&(b=Math.sqrt(mctad.π)*mctad.doubleFactorial(2*a-2)/Math.pow(2,(2*a-1)/2)),b},mctad.gamma=mctad.Γ,mctad.combination=function(a,b){return!mctad.isInteger(a)||0>a||!mctad.isInteger(b)||0>b?void 0:b>a?0:this.factorial(a)/(this.factorial(b)*this.factorial(a-b))},mctad.arithmeticMean=function(a){return Array.isArray(a)&&0!==a.length?this.sum(a)/a.length:void 0},mctad.circularStandardDeviation=function(a){return Array.isArray(a)&&0!==a.length?Math.sqrt(-2*mctad.getBaseLog(10,1-mctad.meanResultantLength(a))):void 0},mctad.circularVariance=function(a){return Array.isArray(a)&&0!==a.length?1-mctad.meanResultantLength(a):void 0},mctad.meanDirection=function(a){if(!Array.isArray(a)||0===a.length)return void 0;for(var b,c,d,e={cos:0,sin:0},f=0;f<a.length;f++)e.cos+=Math.cos(mctad.toRadians(a[f])),e.sin+=Math.sin(mctad.toRadians(a[f]));return b=e.cos/a.length,c=e.sin/a.length,d=b>=0?Math.atan(c/b):Math.atan(c/b)+mctad.π},mctad.meanResultantLength=function(a){if(!Array.isArray(a)||0===a.length)return void 0;for(var b,c,d,e={cos:0,sin:0},f=0;f<a.length;f++)e.cos+=Math.cos(mctad.toRadians(a[f])),e.sin+=Math.sin(mctad.toRadians(a[f]));return b=e.cos/a.length,c=e.sin/a.length,d=Math.sqrt(Math.pow(b,2)+Math.pow(c,2))},mctad.medianDirection=function(){},mctad.geometricMean=function(a){return Array.isArray(a)&&0!==a.length&&this.allPositive(a)?Math.pow(this.product(a),1/a.length):void 0},mctad.mean=function(a){return this.arithmeticMean(a)},mctad.median=function(a){return Array.isArray(a)&&0!==a.length?(this.sortNumeric(a),a.length%2===0?(a[a.length/2-1]+a[a.length/2])/2:a[(a.length+1)/2-1]):null},mctad.mode=function(a){if(!Array.isArray(a)||0===a.length)return null;for(var b=[],c={},d=0,e=0;e<a.length;e++)c.hasOwnProperty(a[e])?c[a[e]]++:c[a[e]]=1,c[a[e]]>d&&(d=c[a[e]]);for(var f in c)c.hasOwnProperty(f)&&c[f]===d&&b.push(parseInt(f));return this.sortNumeric(b),b},mctad.product=function(a){if(!Array.isArray(a)||0===a.length)return void 0;for(var b=1,c=0;c<a.length;c++)b*=a[c];return b},mctad.sampleStandardDeviation=function(a){return Array.isArray(a)&&0!==a.length?Math.sqrt(this.sampleVariance(a)):null},mctad.sampleVariance=function(a){if(!Array.isArray(a)||0===a.length)return void 0;for(var b,c=0,d=0,e=0,f=0,g=0;g<a.length;g++)e++,b=a[g]-c,c+=b/e,f+=b*(a[g]-c);return d=f/(e-1)},mctad.simpleLinearRegression=function(a){if(!Array.isArray(a)||0===a.length)return void 0;for(var b,c,d,e=[],f=[],g=0,h=0,i=0,j=0;j<a.length;j++)e.push(a[j][0]),f.push(a[j][1]);for(x_bar=mctad.arithmeticMean(e),y_bar=mctad.arithmeticMean(f),j=0;j<a.length;j++)g+=(e[j]-x_bar)*(f[j]-y_bar),h+=Math.pow(e[j]-x_bar,2),i+=Math.pow(f[j]-y_bar,2);return b=g/Math.sqrt(h*i),d=b*(mctad.sampleStandardDeviation(f)/mctad.sampleStandardDeviation(e)),c=y_bar-d*x_bar,{x_bar:x_bar,y_bar:y_bar,rxy:b,R2:Math.pow(b,2),"α":c,"β":d}},mctad.sum=function(a){if(!Array.isArray(a)||0===a.length)return void 0;for(var b=0,c=0;c<a.length;c++)b+=a[c];return b},mctad.discreteMixins={p:function(a){return this.hasOwnProperty(a)?this[a].pmf:0},F:function(a){return this.hasOwnProperty(a)?this[a].cdf:a<this.domain.min?0:a>this.domain.max?1:void 0}},mctad.bernoulli=function(a){if(0>a||a>1)return void 0;var b={mean:a,median:function(){return.5>a?0:.5===a?.5:1}(),mode:function(){return.5>a?[0]:.5===a?[0,1]:[1]}(),variance:a*(1-a),skewness:(1-a-a)/Math.sqrt(a*(1-a)),entropy:-(1-a)*Math.log(1-a)-a*Math.log(a),domain:{min:0,max:1},range:{min:0,max:0},generate:function(b){for(var c=[],d=0;b>d;d++)c.push(mctad.getRandomArbitrary(0,1)<=a?1:0);return c}};return b[0]={pmf:1-a,cdf:1-a},b[1]={pmf:a,cdf:1},b.range.max=a>1-a?.1*Math.ceil(10*a):.1*Math.ceil(10*(1-a)),mctad.extend(b,mctad.discreteMixins),b},mctad.binomial=function(a,b){if(0>b||b>1||!mctad.isInteger(a)||0>=a)return void 0;var c,d=0,e=0,f={mean:a*b,median:void 0,mode:function(){return(a+1)*b!==0&&mctad.isInteger((a+1)*b)?mctad.isInteger((a+1)*b)&&(a+1)*b>=1&&a>=(a+1)*b?[(a+1)*b-1,(a+1)*b]:a:[Math.floor((a+1)*b)]}(),variance:a*b*(1-b),skewness:(1-2*b)/Math.sqrt(a*b*(1-b)),entropy:void 0,domain:{min:0,max:1/0},range:{min:0,max:0},generate:function(c){for(var d=[],e=[],f=0;c>f;f++)d=mctad.bernoulli(b).generate(a),e.push(mctad.sum(d));return e}};do c=mctad.factorial(a)/(mctad.factorial(d)*mctad.factorial(a-d))*Math.pow(b,d)*Math.pow(1-b,a-d),e+=c,f[d]={pmf:c,cdf:e},c>f.range.max&&(f.range.max=.1*Math.ceil(10*c)),d++;while(f[d-1].cdf<1-mctad.ε);return f.domain.max=d-1,mctad.extend(f,mctad.discreteMixins),f},mctad.geometric=function(a){if(0>=a||a>1)return void 0;var b,c=0,d=0,e={mean:(1-a)/a,median:void 0,mode:[0],variance:(1-a)/Math.pow(a,2),skewness:(2-a)/Math.sqrt(1-a),entropy:(-(1-a)*(Math.log(1-a)/Math.LN2)-a*(Math.log(a)/Math.LN2))/a,domain:{min:0,max:1/0},range:{min:0,max:0},generate:function(b){for(var c=[],d=0;b>d;d++)c.push(Math.floor(Math.log(mctad.getRandomArbitrary(0,1))/Math.log(1-a)));return c}};do b=a*Math.pow(1-a,c),d+=b,e[c]={pmf:b,cdf:d},b>e.range.max&&(e.range.max=.1*Math.ceil(10*b)),c++;while(e[c-1].cdf<1-mctad.ε);return e.domain.max=c-1,mctad.extend(e,mctad.discreteMixins),e},mctad.hypergeometric=function(a,b,c){if(!mctad.isInteger(a)||!mctad.isInteger(b)||!mctad.isInteger(c)||0>a||0>b||0>c||b>a||c>a)return void 0;var d,e=0,f=0,g={mean:c*b/a,median:void 0,mode:[Math.floor((c+1)*(b+1)/(a+2))],variance:c*(b/a)*((a-b)/a)*((a-c)/(a-1)),skewness:(a-2*b)*Math.sqrt(a-1)*(a-2*c)/(Math.sqrt(c*b*(a-b)*(a-c))*(a-2)),entropy:void 0,domain:{min:0,max:b},range:{min:0,max:0}};for(e=0;c>=e;e++)d=this.combination(b,e)*this.combination(a-b,c-e)/this.combination(a,c),f+=d,g[e]={pmf:d,cdf:f},d>g.range.max&&(g.range.max=.1*Math.ceil(10*d));return mctad.extend(g,mctad.discreteMixins),g},mctad.pascal=function(a,b){if(0>=b||b>=1||!mctad.isInteger(a)||0>=a)return void 0;var c,d=0,e=0,f={mean:a*b/(1-b),median:void 0,mode:function(){return a>1?[Math.floor(b*(a-1)/(1-b))]:[0]}(),variance:a*b/Math.pow(1-b,2),skewness:(1+b)/Math.sqrt(a*b),entropy:void 0,domain:{min:0,max:1/0},range:{min:0,max:0},generate:function(c){for(var d,e,f=[],g=0;c>g;g++){d=0,e=0;do 1===mctad.bernoulli(b).generate(1)[0]?d++:e++;while(a>=e);f.push(d)}return f}};do c=mctad.combination(d+a-1,d)*Math.pow(1-b,a)*Math.pow(b,d),e+=c,f[d]={pmf:c,cdf:e},c>f.range.max&&(f.range.max=.1*Math.ceil(10*c)),d++;while(f[d-1].cdf<1-mctad.ε);return f.domain.max=d-1,mctad.extend(f,mctad.discreteMixins),f},mctad.poisson=function(a){if(0>=a)return void 0;var b,c=0,d=0,e={mean:a,median:Math.floor(a+1/3-.02/a),mode:[Math.ceil(a)-1,Math.floor(a)],variance:a,skewness:Math.pow(a,.5),entropy:void 0,domain:{min:0,max:1/0},range:{min:0,max:0},generate:function(b){for(var c=Math.pow(Math.E,-a),d=[],e=0;b>e;e++){var f=0,g=1;do g*=mctad.getRandomArbitrary(0,1),f++;while(g>c);d.push(f-1)}return d}};do b=Math.pow(Math.E,-a)*Math.pow(a,c)/mctad.factorial(c),d+=b,e[c]={pmf:b,cdf:d},b>e.range.max&&(e.range.max=.1*Math.ceil(10*b)),c++;while(e[c-1].cdf<1-mctad.ε);return e.domain.max=c-1,mctad.extend(e,mctad.discreteMixins),e},mctad.discreteUniform=function(a,b){if(a>b||!mctad.isInteger(a)||!mctad.isInteger(b))return void 0;var c,d,e=0,f={mean:(a+b)/2,median:(a+b)/2,mode:void 0,variance:(Math.pow(b-a+1,2)-1)/12,skewness:0,entropy:Math.log(b-a+1),domain:{min:a,max:b},range:{min:0,max:0},generate:function(c){for(var d=[],e=0;c>e;e++)d.push(mctad.getRandomInt(a,b));return d}};for(c=a;b>=c;c++)d=1/(b-a+1),e+=d,f[c]={pmf:d,cdf:e},d>f.range.max&&(f.range.max=.1*Math.ceil(10*d));return mctad.extend(f,mctad.discreteMixins),f},mctad.chi_squared_distribution_table={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}},mctad.t_distribution_table={1:{.5:0,.6:.325,.75:1,.8:1.376,.85:1.963,.9:3.078,.95:6.314,.975:12.71,.99:31.82,.995:63.66,.9975:127.3,.999:318.3,.9995:636.6},2:{.5:0,.6:.289,.75:.816,.8:1.061,.85:1.386,.9:1.886,.95:2.92,.975:4.303,.99:6.965,.995:9.925,.9975:14.09,.999:22.33,.9995:31.6},3:{.5:0,.6:.277,.75:.765,.8:.978,.85:1.25,.9:1.638,.95:2.353,.975:3.182,.99:4.541,.995:5.841,.9975:7.453,.999:10.21,.9995:12.92},4:{.5:0,.6:.271,.75:.741,.8:.941,.85:1.19,.9:1.533,.95:2.132,.975:2.776,.99:3.747,.995:4.604,.9975:5.598,.999:7.173,.9995:8.61},5:{.5:0,.6:.267,.75:.727,.8:.92,.85:1.156,.9:1.476,.95:2.015,.975:2.571,.99:3.365,.995:4.032,.9975:4.773,.999:5.893,.9995:6.869},6:{.5:0,.6:.265,.75:.718,.8:.906,.85:1.134,.9:1.44,.95:1.943,.975:2.447,.99:3.143,.995:3.707,.9975:4.317,.999:5.208,.9995:5.959},7:{.5:0,.6:.263,.75:.711,.8:.896,.85:1.119,.9:1.415,.95:1.895,.975:2.365,.99:2.998,.995:3.499,.9975:4.029,.999:4.785,.9995:5.408},8:{.5:0,.6:.262,.75:.706,.8:.889,.85:1.108,.9:1.397,.95:1.86,.975:2.306,.99:2.896,.995:3.355,.9975:3.833,.999:4.501,.9995:5.041},9:{.5:0,.6:.261,.75:.703,.8:.883,.85:1.1,.9:1.383,.95:1.833,.975:2.262,.99:2.821,.995:3.25,.9975:3.69,.999:4.297,.9995:4.781},10:{.5:0,.6:.26,.75:.7,.8:.879,.85:1.093,.9:1.372,.95:1.812,.975:2.228,.99:2.764,.995:3.169,.9975:3.581,.999:4.144,.9995:4.587},11:{.5:0,.6:.26,.75:.697,.8:.876,.85:1.088,.9:1.363,.95:1.796,.975:2.201,.99:2.718,.995:3.106,.9975:3.497,.999:4.025,.9995:4.437},12:{.5:0,.6:.259,.75:.695,.8:.873,.85:1.083,.9:1.356,.95:1.782,.975:2.179,.99:2.681,.995:3.055,.9975:3.428,.999:3.93,.9995:4.318},13:{.5:0,.6:.259,.75:.694,.8:.87,.85:1.079,.9:1.35,.95:1.771,.975:2.16,.99:2.65,.995:3.012,.9975:3.372,.999:3.852,.9995:4.221},14:{.5:0,.6:.258,.75:.692,.8:.868,.85:1.076,.9:1.345,.95:1.761,.975:2.145,.99:2.624,.995:2.977,.9975:3.326,.999:3.787,.9995:4.14},15:{.5:0,.6:.258,.75:.691,.8:.866,.85:1.074,.9:1.341,.95:1.753,.975:2.131,.99:2.602,.995:2.947,.9975:3.286,.999:3.733,.9995:4.073},16:{.5:0,.6:.258,.75:.69,.8:.865,.85:1.071,.9:1.337,.95:1.746,.975:2.12,.99:2.583,.995:2.921,.9975:3.252,.999:3.686,.9995:4.015},17:{.5:0,.6:.257,.75:.689,.8:.863,.85:1.069,.9:1.333,.95:1.74,.975:2.11,.99:2.567,.995:2.898,.9975:3.222,.999:3.646,.9995:3.965},18:{.5:0,.6:.257,.75:.688,.8:.862,.85:1.067,.9:1.33,.95:1.734,.975:2.101,.99:2.552,.995:2.878,.9975:3.197,.999:3.61,.9995:3.922},19:{.5:0,.6:.257,.75:.688,.8:.861,.85:1.066,.9:1.328,.95:1.729,.975:2.093,.99:2.539,.995:2.861,.9975:3.174,.999:3.579,.9995:3.883},20:{.5:0,.6:.257,.75:.687,.8:.86,.85:1.064,.9:1.325,.95:1.725,.975:2.086,.99:2.528,.995:2.845,.9975:3.153,.999:3.552,.9995:3.85},21:{.5:0,.6:.257,.75:.686,.8:.859,.85:1.063,.9:1.323,.95:1.721,.975:2.08,.99:2.518,.995:2.831,.9975:3.135,.999:3.527,.9995:3.819},22:{.5:0,.6:.256,.75:.686,.8:.858,.85:1.061,.9:1.321,.95:1.717,.975:2.074,.99:2.508,.995:2.819,.9975:3.119,.999:3.505,.9995:3.792},23:{.5:0,.6:.256,.75:.685,.8:.858,.85:1.06,.9:1.319,.95:1.714,.975:2.069,.99:2.5,.995:2.807,.9975:3.104,.999:3.485,.9995:3.767},24:{.5:0,.6:.256,.75:.685,.8:.857,.85:1.059,.9:1.318,.95:1.711,.975:2.064,.99:2.492,.995:2.797,.9975:3.091,.999:3.467,.9995:3.745},25:{.5:0,.6:.256,.75:.684,.8:.856,.85:1.058,.9:1.316,.95:1.708,.975:2.06,.99:2.485,.995:2.787,.9975:3.078,.999:3.45,.9995:3.725},26:{.5:0,.6:.256,.75:.684,.8:.856,.85:1.058,.9:1.315,.95:1.706,.975:2.056,.99:2.479,.995:2.779,.9975:3.067,.999:3.435,.9995:3.707},27:{.5:0,.6:.256,.75:.684,.8:.855,.85:1.057,.9:1.314,.95:1.703,.975:2.052,.99:2.473,.995:2.771,.9975:3.057,.999:3.421,.9995:3.69},28:{.5:0,.6:.256,.75:.683,.8:.855,.85:1.056,.9:1.313,.95:1.701,.975:2.048,.99:2.467,.995:2.763,.9975:3.047,.999:3.408,.9995:3.674},29:{.5:0,.6:.256,.75:.683,.8:.854,.85:1.055,.9:1.311,.95:1.699,.975:2.045,.99:2.462,.995:2.756,.9975:3.038,.999:3.396,.9995:3.659},30:{.5:0,.6:.256,.75:.683,.8:.854,.85:1.055,.9:1.31,.95:1.697,.975:2.042,.99:2.457,.995:2.75,.9975:3.03,.999:3.385,.9995:3.646},40:{.5:0,.6:.255,.75:.681,.8:.851,.85:1.05,.9:1.303,.95:1.684,.975:2.021,.99:2.423,.995:2.704,.9975:2.971,.999:3.307,.9995:3.551},50:{.5:0,.6:.255,.75:.679,.8:.849,.85:1.047,.9:1.299,.95:1.676,.975:2.009,.99:2.403,.995:2.678,.9975:2.937,.999:3.261,.9995:3.496},60:{.5:0,.6:.254,.75:.679,.8:.848,.85:1.045,.9:1.296,.95:1.671,.975:2,.99:2.39,.995:2.66,.9975:2.915,.999:3.232,.9995:3.46},80:{.5:0,.6:.254,.75:.678,.8:.846,.85:1.043,.9:1.292,.95:1.664,.975:1.99,.99:2.374,.995:2.639,.9975:2.887,.999:3.195,.9995:3.416},100:{.5:0,.6:.254,.75:.677,.8:.845,.85:1.042,.9:1.29,.95:1.66,.975:1.984,.99:2.364,.995:2.626,.9975:2.871,.999:3.174,.9995:3.39},120:{.5:0,.6:.254,.75:.677,.8:.845,.85:1.041,.9:1.289,.95:1.658,.975:1.98,.99:2.358,.995:2.617,.9975:2.86,.999:3.16,.9995:3.373}},mctad.continuousMixins={f:function(a){return this.pdf(a)},F:function(a){return this.cdf(a)}},mctad.erf=function(a){return 1-1/Math.pow(1+.0705230784*a+.0422820123*Math.pow(a,2)+.0092705272*Math.pow(a,3)+.0001520143*Math.pow(a,4)+.0002765672*Math.pow(a,5)+430638e-10*Math.pow(a,6),16)},mctad.chiSquared=function(a){if(0>=a||!mctad.isInteger(a))return void 0;var b={mean:a,median:a*Math.pow(1-2/(9*a),3),mode:Math.max(a-2,0),variance:2*a,skewness:Math.sqrt(8/a),entropy:void 0,domain:{min:0,max:1/0},range:{min:0,max:1/0},generate:function(){return void 0},pdf:function(b){return b>0?1/(Math.pow(2,a/2)*mctad.Γ(a/2))*Math.pow(b,a/2-1)*Math.pow(Math.E,-b/2):0},cdf:function(b){var c=[];for(var d in mctad.chi_squared_distribution_table[a])c.push([1-parseFloat(d),parseFloat(mctad.chi_squared_distribution_table[a][d])]);c.sort(function(a,b){return a[1]-b[1]});for(var e=0;c[e][1]<b&&e<c.length;)e++;return c[e][0]}};return mctad.extend(b,mctad.continuousMixins),b.domain.max=Math.ceil(2*b.variance),b.range.max=function(){return a>2?.1*Math.ceil(10*b.pdf(b.mode)):2===a?.5:5.5}(),b},mctad.exponential=function(a){if(0>a)return void 0;var b={mean:1/a,median:1/a*Math.log(2),mode:0,variance:Math.pow(1/a,2),skewness:2,entropy:1-Math.log(a),domain:{min:0,max:1/0},range:{min:0,max:1/0},generate:function(b){for(var c=[],d=0;b>d;d++)c.push(-(1/a)*Math.log(mctad.getRandomArbitrary(0,1)));return c},pdf:function(b){return b>=0?a*Math.pow(Math.E,-a*b):void 0},cdf:function(b){return b>=0?1-Math.pow(Math.E,-a*b):0}};return mctad.extend(b,mctad.continuousMixins),b.domain.max=Math.ceil(4*b.variance),b.range.max=.1*Math.ceil(10*b.pdf(0)),b},mctad.inverseErf=function(a){var b=.147;return mctad.sign(a)*Math.sqrt(Math.sqrt(Math.pow(2/(mctad.π*b)+Math.log(1-Math.pow(a,2))/2,2)-Math.log(1-Math.pow(a,2))/b)-(2/(mctad.π*b)+Math.log(1-Math.pow(a,2))/2))},mctad.lognormal=function(a,b){if(0>a||0>=b)return void 0;var c={mean:Math.pow(Math.E,a+b/2),median:Math.pow(Math.E,a),mode:Math.pow(Math.E,a-b),variance:Math.pow(Math.E,2*a+b)*(Math.pow(Math.E,b)-1),skewness:(Math.pow(Math.E,b)+2)*Math.sqrt(Math.pow(Math.E,b)-1),entropy:.5+.5*Math.log(2*mctad.π*b)+a,domain:{min:0,max:1/0},range:{min:0,max:1/0},generate:function(c){var d=[];d=mctad.normal(a,b).generate(c);for(var e=0;c>e;e++)d[e]=Math.pow(Math.E,d[e]);return d},pdf:function(c){return c>0?1/(c*Math.sqrt(2*mctad.π*b))*Math.pow(Math.E,-(Math.pow(Math.log(c)-a,2)/(2*b))):void 0},cdf:function(c){if(c>0){var d=(Math.log(c)-a)/Math.sqrt(b);return mctad.normal(0,1).F(d)}return 0}};return mctad.extend(c,mctad.continuousMixins),c.domain.max=a+Math.ceil(2.5*c.variance),c.range.max=.1*Math.ceil(10*c.pdf(c.mode)),c},mctad.normal=function(a,b){if(0>=b)return void 0;var c={mean:a,median:a,mode:a,variance:b,skewness:0,entropy:.5*Math.log(2*mctad.π*Math.E*b),domain:{min:-1/0,max:1/0},range:{min:0,max:1/0},generate:function(c){for(var d,e,f=[],g=[],h=[],i=0;c/2>i;i++){do f=[mctad.getRandomArbitrary(0,1),mctad.getRandomArbitrary(0,1)],g=[2*f[0]-1,2*f[1]-1],d=Math.pow(g[0],2)+Math.pow(g[1],2);while(d>1);e=Math.sqrt(-2*Math.log(d)/d),h.push(a+Math.sqrt(b)*g[0]*e,a+Math.sqrt(b)*g[1]*e)}return h.length===c+1&&h.pop(),h},pdf:function(c){return 1/(Math.sqrt(b)*Math.sqrt(2*mctad.π))*Math.pow(Math.E,-(Math.pow(c-a,2)/(2*b)))},cdf:function(c){var d=(c-a)/Math.sqrt(2*b);return d>=0?.5*(1+mctad.erf(d)):.5*(1-mctad.erf(-d))}};return mctad.extend(c,mctad.continuousMixins),c.domain.min=a-Math.ceil(3*c.variance),c.domain.max=a+Math.ceil(3*c.variance),c.range.max=.1*Math.ceil(10*c.pdf(a)),c},mctad.studentsT=function(a){if(0>=a)return void 0;var b={mean:function(){return a>1?0:void 0}(),median:0,mode:0,variance:function(){return a>2?a/(a-2):a>1?1/0:void 0}(),skewness:function(){return a>3?0:void 0}(),entropy:"to be implemented",domain:{min:-1/0,max:1/0},range:{min:0,max:1/0},pdf:function(b){return mctad.Γ((a+1)/2)/(Math.sqrt(a*mctad.π)*mctad.Γ(a/2))*Math.pow(1+Math.pow(b,2)/a,-((a+1)/2))},cdf:function(b){var c=[];for(var d in mctad.t_distribution_table[a])c.push([parseFloat(d),parseFloat(mctad.t_distribution_table[a][d])]),c.push([parseFloat(1-d),parseFloat(-mctad.t_distribution_table[a][d])]);c.sort(function(a,b){return a[1]-b[1]});for(var e=0;c[e][1]<b;)e++;return c[e][0]}};return mctad.extend(b,mctad.continuousMixins),b.domain.min=-Math.ceil(3*b.variance),b.domain.max=Math.ceil(3*b.variance),b.range.max=.1*Math.ceil(10*b.pdf(0)),b},mctad.triangular=function(a,b,c){if(a>=b||a>=c||c>=b)return void 0;var d={mean:(a+b+c)/3,median:function(){return c>(a+b)/2?a+Math.sqrt((b-a)*(c-a))/Math.sqrt(2):b-Math.sqrt((b-a)*(b-c))/Math.sqrt(2)}(),mode:c,variance:(Math.pow(a,2)+Math.pow(b,2)+Math.pow(c,2)-a*b-a*c-b*c)/18,skewness:Math.sqrt(2)*(a+b-2*c)*(2*a-b-c)*(a-2*b+c)/(5*Math.pow(Math.pow(a,2)+Math.pow(b,2)+Math.pow(c,2)-a*b-a*c-b*c,1.5)),entropy:.5+Math.log((b-a)/2),domain:{min:a,max:b},range:{min:0,max:1/0},generate:function(d){for(var e=(c-a)/(b-a),f=[],g=0;d>g;g++){var h=mctad.getRandomArbitrary(0,1);f.push(e>=h?a+(b-a)*Math.sqrt(e*h):a+(b-a)*(1-Math.sqrt((1-e)*(1-h))))}return f},pdf:function(d){return d>=a&&c>=d?2*(d-a)/((b-a)*(c-a)):d>c&&b>=d?2*(b-d)/((b-a)*(b-c)):0},cdf:function(d){return a>d?0:d>=a&&c>=d?Math.pow(d-a,2)/((b-a)*(c-a)):d>c&&b>=d?1-Math.pow(b-d,2)/((b-a)*(b-c)):1}};return mctad.extend(d,mctad.continuousMixins),d.range.max=.1*Math.ceil(10*d.pdf(c)),d},mctad.uniform=function(a,b){if(a>=b)return void 0;var c={mean:(a+b)/2,median:(a+b)/2,mode:void 0,variance:Math.pow(b-a,2)/12,skewness:0,entropy:Math.log(b-a),domain:{min:a,max:b},range:{min:0,max:1/0},generate:function(c){for(var d=[],e=0;c>e;e++)d.push(a+(b-a)*mctad.getRandomArbitrary(0,1));return d},pdf:function(c){return c>=a&&b>=c?1/(b-a):0},cdf:function(c){return a>c?0:c>=a&&b>=c?(c-a)/(b-a):1}};return mctad.extend(c,mctad.continuousMixins),c.range.max=.1*Math.ceil(10*c.pdf(a)),c},mctad.weibull=function(a,b){if(0>a||0>b)return void 0;var c={mean:a*mctad.Γ(1+1/b),median:a*Math.pow(Math.log(2),1/b),mode:function(){return b>=1?a*Math.pow((b-1)/b,1/b):0}(),variance:Math.pow(a,2)*(mctad.Γ(1+2/b)-Math.pow(mctad.Γ(1+1/b),2)),skewness:void 0,entropy:void 0,domain:{min:0,max:1/0},range:{min:0,max:1/0},generate:function(b){for(var c=[],d=0;b>d;d++)c.push(-(1/a)*Math.log(mctad.getRandomArbitrary(0,1)));return c},pdf:function(c){return c>=0?b/a*Math.pow(c/a,b-1)*Math.pow(Math.E,-Math.pow(c/a,b)):0},cdf:function(c){return c>=0?1-Math.pow(Math.E,-Math.pow(c/a,b)):0}};return mctad.extend(c,mctad.continuousMixins),c.domain.max=Math.ceil(6*c.variance),c.range.max=.1*Math.ceil(10*c.pdf(c.mode)),c},mctad.confidenceIntervalOnTheDifferenceBetweenTwoMeans=function(a,b,c,d,e,f,g,h){if("number"!=typeof a||"number"!=typeof b||"number"!=typeof c||"number"!=typeof d||!mctad.isInteger(e)||!mctad.isInteger(f)||0>=g||g>=1)return void 0;var i,j=a-c,k=Math.sqrt(Math.pow(b,2)/e+Math.pow(d,2)/f);return e>30&&f>30?"undefined"!=typeof h&&"u"===h.toLowerCase()?j+mctad.z(1-g)*k:"undefined"!=typeof h&&"l"===h.toLowerCase()?j-mctad.z(1-g)*k:[j-mctad.z(1-g/2)*k,j+mctad.z(1-g/2)*k]:(i=Math.floor(Math.pow(Math.pow(b,2)/e+Math.pow(d,2)/f,2)/(Math.pow(Math.pow(b,2)/e,2)/(e-1)+Math.pow(Math.pow(d,2)/f,2)/(f-1))),"undefined"!=typeof h&&"u"===h.toLowerCase()?j+mctad.t_distribution_table[i][1-g]*k:"undefined"!=typeof h&&"l"===h.toLowerCase()?j-mctad.t_distribution_table[i][1-g]*k:[j-mctad.t_distribution_table[i][1-g/2]*k,j+mctad.t_distribution_table[i][1-g/2]*k])},mctad.confidenceIntervalOnTheDifferenceBetweenTwoProportions=function(a,b,c,d,e,f){if("number"!=typeof a||"number"!=typeof b||!mctad.isInteger(c)||!mctad.isInteger(d)||0>=e||e>=1)return void 0;var g=c+2,h=d+2,i=(a+1)/g,j=(b+1)/h,k=i-j,l=Math.sqrt(i*(1-i)/g+j*(1-j)/h);return"undefined"!=typeof f&&"u"===f.toLowerCase()?k+mctad.z(1-e)*l:"undefined"!=typeof f&&"l"===f.toLowerCase()?k-mctad.z(1-e)*l:[k-mctad.z(1-e/2)*l,k+mctad.z(1-e/2)*l]},mctad.confidenceIntervalOnTheMean=function(a,b,c,d,e){if("number"!=typeof a||"number"!=typeof b||!mctad.isInteger(c)||0>=d||d>=1)return void 0;var f=b/Math.sqrt(c);return c>30?"undefined"!=typeof e&&"u"===e.toLowerCase()?a+mctad.z(1-d)*f:"undefined"!=typeof e&&"l"===e.toLowerCase()?a-mctad.z(1-d)*f:[a-mctad.z(1-d/2)*f,a+mctad.z(1-d/2)*f]:"undefined"!=typeof e&&"u"===e.toLowerCase()?a+mctad.t_distribution_table[c-1][1-d]*f:"undefined"!=typeof e&&"l"===e.toLowerCase()?a-mctad.t_distribution_table[c-1][1-d]*f:[a-mctad.t_distribution_table[c-1][1-d/2]*f,a+mctad.t_distribution_table[c-1][1-d/2]*f]},mctad.confidenceIntervalOnTheProportion=function(a,b,c,d){if("number"!=typeof a||!mctad.isInteger(b)||0>=c||c>=1)return void 0;var e=b+4,f=(a+2)/e,g=Math.sqrt(f*(1-f)/e);return"undefined"!=typeof d&&"u"===d.toLowerCase()?f+mctad.z(1-c)*g:"undefined"!=typeof d&&"l"===d.toLowerCase()?Math.max(0,f-mctad.z(1-c)*g):[Math.max(0,f-mctad.z(1-c/2)*g),f+mctad.z(1-c/2)*g]},mctad.z=function(a){return 0>=a||a>=1?void 0:Math.sqrt(2)*mctad.inverseErf(2*a-1)};