//>>built
define("dojox/math/stats",["dojo","../main"],function(j,k){j.getObject("math.stats",!0,k);var g=k.math.stats;j.mixin(g,{sd:function(a){return Math.sqrt(g.variance(a))},variance:function(a){var b=0,c=0;j.forEach(a,function(a){b+=a;c+=Math.pow(a,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=j.map(a,function(a,b){return{x:b,y:a}}));for(var d=0,e=0,h=0,g=0,i=0,k=0,n=0,l=a.length,m,f=0;f<l;f++)d+=a[f][b],e+=a[f][c],h+=
Math.pow(a[f][b],2),g+=Math.pow(a[f][c],2),i+=a[f][b]*a[f][c];for(f=0;f<l;f++)m=a[f][b]-d/l,k+=m*m,n+=m*a[f][c];a=n/(k||1);h=Math.sqrt((h-Math.pow(d,2)/l)*(g-Math.pow(e,2)/l));if(0===h)throw Error("dojox.math.stats.bestFit: the denominator for Pearson's R is 0.");i=(i-d*e/l)/h;h=Math.pow(i,2);0>a&&(i=-i);return{slope:a,intercept:(e-d*a)/(l||1),r:i,r2:h}},forecast:function(a,b,c,d){a=g.bestFit(a,c,d);return a.slope*b+a.intercept},mean:function(a){var b=0;j.forEach(a,function(a){b+=a});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(a,b){return a-b});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;j.forEach(a,function(a){void 0!==b[a]?b[a]++:b[a]=1});for(var e in b)d<b[e]&&(d=b[e],c=e);return c},sum:function(a){var b=0;j.forEach(a,function(a){b+=a});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(a,b){return a-b}));var c=g.approxLin;return{min:a[0],p25:c(a,0.25),med:c(a,0.5),p75:c(a,0.75),max:a[a.length-1],p10:c(a,0.1),p90:c(a,0.9)}}});return k.math.stats});