//>>built
define("dojox/math/stats",["dojo","../main"],function(h,p){h.getObject("math.stats",!0,p);var m=p.math.stats;h.mixin(m,{sd:function(a){return Math.sqrt(m.variance(a))},variance:function(a){var b=0,c=0;h.forEach(a,function(d){b+=d;c+=Math.pow(d,2)});return c/a.length-Math.pow(b/a.length,2)},bestFit:function(a,b,c){b=b||"x";c=c||"y";void 0!==a[0]&&"number"==typeof a[0]&&(a=h.map(a,function(u,v){return{x:v,y:u}}));for(var d=0,e=0,g=0,q=0,k=0,r=0,t=0,l=a.length,n,f=0;f<l;f++)d+=a[f][b],e+=a[f][c],g+=
Math.pow(a[f][b],2),q+=Math.pow(a[f][c],2),k+=a[f][b]*a[f][c];for(f=0;f<l;f++)n=a[f][b]-d/l,r+=n*n,t+=n*a[f][c];a=t/(r||1);g=Math.sqrt((g-Math.pow(d,2)/l)*(q-Math.pow(e,2)/l));if(0===g)throw Error("dojox.math.stats.bestFit: the denominator for Pearson's R is 0.");k=(k-d*e/l)/g;g=Math.pow(k,2);0>a&&(k=-k);return{slope:a,intercept:(e-d*a)/(l||1),r:k,r2:g}},forecast:function(a,b,c,d){a=m.bestFit(a,c,d);return a.slope*b+a.intercept},mean:function(a){var b=0;h.forEach(a,function(c){b+=c});return b/Math.max(a.length,
1)},min:function(a){return Math.min.apply(null,a)},max:function(a){return Math.max.apply(null,a)},median:function(a){var b=a.slice(0).sort(function(c,d){return c-d});return(b[Math.floor(a.length/2)]+b[Math.ceil(a.length/2)])/2},mode:function(a){var b={},c=0,d=Number.MIN_VALUE;h.forEach(a,function(g){void 0!==b[g]?b[g]++:b[g]=1});for(var e in b)d<b[e]&&(d=b[e],c=e);return c},sum:function(a){var b=0;h.forEach(a,function(c){b+=c});return b},approxLin:function(a,b){var c=b*(a.length-1),d=Math.ceil(c),
e=d-1;return 0>e?a[0]:d>=a.length?a[a.length-1]:a[e]*(d-c)+a[d]*(c-e)},summary:function(a,b){b||(a=a.slice(0),a.sort(function(d,e){return d-e}));var c=m.approxLin;return{min:a[0],p25:c(a,.25),med:c(a,.5),p75:c(a,.75),max:a[a.length-1],p10:c(a,.1),p90:c(a,.9)}}});return p.math.stats});