(function(){function h(a,b){var c=b+1;while(c=a[c])return!1;return!0}function d(a){var b=a.length,c=-1;while(++cd)return null;var e=[],f=[],g={},h=0,i=0,j,k,l;while(ie&&(e=f);return e},hamming:function(a,b){var c=a.length,d=-1,e=0;while(++d=-1?.5:0},triangular:function(a){return a<=1&&a>=-1?1-Math.abs(a):0},epanechnikov:function(a){return a<=1&&a>=-1?.75*(1-a*a):0},quartic:function(a){if(a<=1&&a>=-1){var b=1-a*a;return.9375*b*b}return 0},triweight:function(a){if(a<=1&&a>=-1){var b=1-a*a;return 35/32*b*b*b}return 0},gaussian:function(a){return 1/Math.sqrt(2*Math.PI)*Math.exp(-0.5*a*a)},cosine:function(a){return a<=1&&a>=-1?Math.PI/4*Math.cos(Math.PI/2*a):0}},science.stats.kde=function(){function d(d,e){var f=c.call(this,b);return d.map(function(c){var d=-1,e=0,g=b.length;while(++dh[p][q]&&(f[p]=q)}p=-1;while(++ph[k][q]&&(h[q][j]=h[j][q]=h[k][q]);break;case"complete":h[j][q]0&&g(h,j,l,r);var t=r[0],u=r[1],v=h[l]-h[t]>h[u]-h[l]?t:u,w=0,x=0,y=0,z=0,A=0,B=Math.abs(1/(h[v]-s));for(var C=t;C<=u;++C){var D=h[C],E=i[C],F=C=1?0:(G=1-Q*Q)*G}return n}var a=.3,b=2,c=1e-12;h.bandwidth=function(b){if(!arguments.length)return b;a=b;return h},h.robustnessIterations=function(a){if(!arguments.length)return a;b=a;return h},h.accuracy=function(a){if(!arguments.length)return a;c=a;return h};return h},science.stats.mean=function(a){var b=a.length;if(b===0)return NaN;var c=0,d=-1;while(++dg&&(g=h,b=f),f=i,e=d);return b},science.stats.quantiles=function(a,b){a=a.slice().sort(science.ascending);var c=a.length-1;return b.map(function(b){if(b===0)return a[0];if(b===1)return a[c];var d=1+b*c,e=Math.floor(d),f=d-e,g=a[e-1];return f===0?g:g+f*(a[e]-g)})},science.stats.variance=function(a){var b=a.length;if(b<1)return NaN;if(b===1)return 0;var c=science.stats.mean(a),d=-1,e=0;while(++d