Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
js.jstat.min.js Maven / Gradle / Ivy
this.j$=this.jStat=function(a,b){function j(){return new j.fn.init(arguments)}var c=Array.prototype.slice,d=Object.prototype.toString,e=function(b,c){var d=b>c?b:c;return a.pow(10,17-~~(a.log(d>0?d:-d)*a.LOG10E))},f=Array.isArray||function(a){return d.call(a)==="[object Array]"},g=function(a){return d.call(a)==="[object Function]"},h=function(a){return d.call(a)==="[object Number]"&&!isNaN(a)},i=function(a){return[].concat.apply([],a)};return j.fn=j.prototype={constructor:j,init:function(a){var b=0;if(f(a[0]))if(f(a[0][0])){g(a[1])&&(a[0]=j.map(a[0],a[1]));for(;b1?c.call(this):c.call(this)[0]},push:[].push,sort:[].sort,splice:[].splice,slice:[].slice},j.fn.init.prototype=j.fn,j.utils={calcRdx:e,isArray:f,isFunction:g,isNumber:h,toVector:i},j.extend=function(a){var b=c.call(arguments),d=1,e;if(b.length===1){for(e in a)j[e]=a[e];return this}for(;d=0;b--,d++)c[d]=[a[d][b]];return c},transpose:function(a){var b=[],c=0,d,e,g;f(a[0])||(a=[a]),d=a.length,e=a[0].length;for(;c=0)b+=a[c];return b},sumsqrd:function(a){var b=0,c=a.length;while(--c>=0)b+=a[c]*a[c];return b},sumsqerr:function(b){var c=a.mean(b),d=0,e=b.length,f;while(--e>=0)f=b[e]-c,d+=f*f;return d},product:function(a){var b=1,c=a.length;while(--c>=0)b*=a[c];return b},min:function(a){var b=a[0],c=0;while(++cb&&(b=a[c]);return b},mean:function(b){return a.sum(b)/b.length},meansqerr:function(b){return a.sumsqerr(b)/b.length},geomean:function(c){return b.pow(a.product(c),1/c.length)},median:function(a){var b=a.length,c=a.slice().sort(d);return b&1?c[b/2|0]:(c[b/2-1]+c[b/2])/2},cumsum:function(a){var b=a.length,c=new Array(b),d=1;c[0]=a[0];for(;df?(i=[c[h]],f=e,g=0):e===f&&(i.push(c[h]),g++),e=1);return g===0?i[0]:i},range:function(b){return a.max(b)-a.min(b)},variance:function(b,c){return a.sumsqerr(b)/(b.length-(c?1:0))},stdev:function(c,d){return b.sqrt(a.variance(c,d))},meandev:function(c){var d=0,e=a.mean(c),f=c.length-1;for(;f>=0;f--)d+=b.abs(c[f]-e);return d/c.length},meddev:function(c){var d=0,e=a.median(c),f=c.length-1;for(;f>=0;f--)d+=b.abs(c[f]-e);return d/c.length},coeffvar:function(b){return a.stdev(b)/a.mean(b)},quartiles:function(a){var c=a.length,e=a.slice().sort(d);return[e[b.round(c/4)-1],e[b.round(c/2)-1],e[b.round(c*3/4)-1]]},covariance:function(b,c){var d=a.mean(b),e=a.mean(c),f=b.length,g=new Array(f),h=0;for(;h1){h=d===!0?this:this.transpose();for(;g1){g=b===!0?this:this.transpose();for(;fi)for(j=0;j=1?c:1/c)*8.5+c*.4+17),o,p;if(d<0||c<=0)return NaN;if(d170||d>170?b.exp(a.combinationln(c,d)):a.factorial(c)/a.factorial(d)/a.factorial(c-d)},combinationln:function(b,c){return a.factorialln(b)-a.factorialln(c)-a.factorialln(b-c)},permutation:function(b,c){return a.factorial(b)/a.factorial(b-c)},betafn:function(c,d){return c<=0||d<=0?undefined:c+d>170?b.exp(a.betaln(c,d)):a.gammafn(c)*a.gammafn(d)/a.gammafn(c+d)},betaln:function(b,c){return a.gammaln(b)+a.gammaln(c)-a.gammaln(b+c)},betacf:function(a,c,d){var e=1e-30,f=1,g,h,i,j,k,l,m,n,o;m=c+d,o=c+1,n=c-1,i=1,j=1-m*a/o,b.abs(j)=1)return b.max(100,d+100*b.sqrt(d));if(c<=0)return 0;d>1?(n=b.log(f),o=b.exp(f*(n-1)-h),m=c<.5?c:1-c,k=b.sqrt(-2*b.log(m)),i=(2.30753+k*.27061)/(1+k*(.99229+k*.04481))-k,c<.5&&(i=-i),i=b.max(.001,d*b.pow(1-1/(9*d)-i/(3*b.sqrt(d)),3))):(k=1-d*(.253+d*.12),c1?k=o*b.exp(-(i-f)+f*(b.log(i)-n)):k=b.exp(-i+f*b.log(i)-h),l=j/k,i-=k=l/(1-.5*b.min(1,l*((d-1)/i-1))),i<=0&&(i=.5*(i+k));if(b.abs(k)0;d--)j=f,f=i*f-g+c[d],g=j;return k=h*b.exp(-a*a+.5*(c[0]+i*f)-g),e?k-1:1-k},erfc:function(b){return 1-a.erf(b)},erfcinv:function(c){var d=0,e,f,g,h;if(c>=2)return-100;if(c<=0)return 100;h=c<1?c:2-c,g=b.sqrt(-2*b.log(h/2)),e=-0.70711*((2.30753+g*.27061)/(1+g*(.99229+g*.04481))-g);for(;d<2;d++)f=a.erfc(e)-h,e+=f/(1.1283791670955126*b.exp(-e*e)-e*f);return c<1?e:-e},ibetainv:function(c,d,e){var f=1e-8,g=d-1,h=e-1,i=0,j,k,l,m,n,o,p,q,r,s,t;if(c<=0)return 0;if(c>=1)return 1;d>=1&&e>=1?(l=c<.5?c:1-c,m=b.sqrt(-2*b.log(l)),p=(2.30753+m*.27061)/(1+m*(.99229+m*.04481))-m,c<.5&&(p=-p),q=(p*p-3)/6,r=2/(1/(2*d-1)+1/(2*e-1)),s=p*b.sqrt(q+r)/r-(1/(2*e-1)-1/(2*d-1))*(q+5/6-2/(3*r)),p=d/(d+e*b.exp(2*s))):(j=b.log(d/(d+e)),k=b.log(e/(d+e)),m=b.exp(d*j)/d,n=b.exp(e*k)/e,s=m+n,c=1&&(p=.5*(p+m+1));if(b.abs(m)0)break}return p},ibeta:function(c,d,e){var f=c===0||c===1?0:b.exp(a.gammaln(d+e)-a.gammaln(d)-a.gammaln(e)+d*b.log(c)+e*b.log(1-c));return c<0||c>1?!1:c<(d+1)/(d+e+2)?f*a.betacf(c,d,e)/d:1-f*a.betacf(1-c,e,d)/e},randn:function(c,d){var e,f,g,h,i,j;d||(d=c);if(c)return a.create(c,d,function(){return a.randn()});do e=b.random(),f=1.7156*(b.random()-.5),g=e-.449871,h=b.abs(f)+.386595,i=g*g+h*(.196*h-.25472*g);while(i>.27597&&(i>.27846||f*f>-4*b.log(e)*e*e));return f/e},randg:function(c,d,e){var f=c,g,h,i,j,k,l;e||(e=d),c||(c=1);if(d)return l=a.zeros(d,e),l.alter(function(){return a.randg(c)}),l;c<1&&(c+=1),g=c-1/3,h=1/b.sqrt(9*g);do{do k=a.randn(),j=1+h*k;while(j<=0);j=j*j*j,i=b.random()}while(i>1-.331*b.pow(k,4)&&b.log(i)>.5*k*k+g*(1-j+b.log(j)));if(c==f)return g*j;do i=b.random();while(i===0);return b.pow(i,1/f)*g*j}}),function(b){for(var c=0;c1||c<0?0:b.pow(c,d-1)*b.pow(1-c,e-1)/a.betafn(d,e)},cdf:function(b,c,d){return b>1||b<0?(b>1)*1:a.ibeta(b,c,d)},inv:function(b,c,d){return a.ibetainv(b,c,d)},mean:function(a,b){return a/(a+b)},median:function(a,b){},mode:function(a,c){return a*c/(b.pow(a+c,2)*(a+c+1))},sample:function(b,c){var d=a.randg(b);return d/(d+a.randg(c))},variance:function(a,c){return a*c/(b.pow(a+c,2)*(a+c+1))}}),a.extend(a.centralF,{pdf:function(c,d,e){return c>=0?b.sqrt(b.pow(d*c,d)*b.pow(e,e)/b.pow(d*c+e,d+e))/(c*a.betafn(d/2,e/2)):undefined},cdf:function(b,c,d){return a.ibeta(c*b/(c*b+d),c/2,d/2)},inv:function(b,c,d){return d/(c*(1/a.ibetainv(b,c/2,d/2)-1))},mean:function(a,b){return b>2?b/(b-2):undefined},mode:function(a,b){return a>2?b*(a-2)/(a*(b+2)):undefined},sample:function(b,c){var d=a.randg(b/2)*2,e=a.randg(c/2)*2;return d/b/(e/c)},variance:function(a,b){return b>4?2*b*b*(a+b-2)/(a*(b-2)*(b-2)*(b-4)):undefined}}),a.extend(a.cauchy,{pdf:function(a,c,d){return d/(b.pow(a-c,2)+b.pow(d,2))/b.PI},cdf:function(a,c,d){return b.atan((a-c)/d)/b.PI+.5},inv:function(a,c,d){return c+d*b.tan(b.PI*(a-.5))},median:function(a,b){return a},mode:function(a,b){return a},sample:function(c,d){return a.randn()*b.sqrt(1/(2*a.randg(.5)))*d+c}}),a.extend(a.chisquare,{pdf:function(c,d){return b.exp((d/2-1)*b.log(c)-c/2-d/2*b.log(2)-a.gammaln(d/2))},cdf:function(b,c){return a.gammap(c/2,b/2)},inv:function(b,c){return 2*a.gammapinv(b,.5*c)},mean:function(a){return a},median:function(a){return a*b.pow(1-2/(9*a),3)},mode:function(a){return a-2>0?a-2:0},sample:function(b){return a.randg(b/2)*2},variance:function(a){return 2*a}}),a.extend(a.exponential,{pdf:function(a,c){return a<0?0:c*b.exp(-c*a)},cdf:function(a,c){return a<0?0:1-b.exp(-c*a)},inv:function(a,c){return-b.log(1-a)/c},mean:function(a){return 1/a},median:function(a){return 1/a*b.log(2)},mode:function(a){return 0},sample:function(a){return-1/a*b.log(b.random())},variance:function(a){return b.pow(a,-2)}}),a.extend(a.gamma,{pdf:function(c,d,e){return b.exp((d-1)*b.log(c)-c/e-a.gammaln(d)-d*b.log(e))},cdf:function(b,c,d){return a.gammap(c,b/d)},inv:function(b,c,d){return a.gammapinv(b,c)*d},mean:function(a,b){return a*b},mode:function(a,b){return a>1?(a-1)*b:undefined},sample:function(b,c){return a.randg(b)*c},variance:function(a,b){return a*b*b}}),a.extend(a.invgamma,{pdf:function(c,d,e){return b.exp(-(d+1)*b.log(c)-e/c-a.gammaln(d)+d*b.log(e))},cdf:function(b,c,d){return 1-a.gammap(c,d/b)},inv:function(b,c,d){return d/a.gammapinv(1-b,c)},mean:function(a,b){return a>1?b/(a-1):undefined},mode:function(a,b){return b/(a+1)},sample:function(b,c){return c/a.randg(b)},variance:function(a,b){return a>2?b*b/((a-1)*(a-1)*(a-2)):undefined}}),a.extend(a.kumaraswamy,{pdf:function(a,c,d){return b.exp(b.log(c)+b.log(d)+(c-1)*b.log(a)+(d-1)*b.log(1-b.pow(a,c)))},cdf:function(a,c,d){return 1-b.pow(1-b.pow(a,c),d)},mean:function(b,c){return c*a.gammafn(1+1/b)*a.gammafn(c)/a.gammafn(1+1/b+c)},median:function(a,c){return b.pow(1-b.pow(2,-1/c),1/a)},mode:function(a,c){return a>=1&&c>=1&&a!==1&&c!==1?b.pow((a-1)/(a*c-1),1/a):undefined},variance:function(a,b){}}),a.extend(a.lognormal,{pdf:function(a,c,d){return b.exp(-b.log(a)-.5*b.log(2*b.PI)-b.log(d)-b.pow(b.log(a)-c,2)/(2*d*d))},cdf:function(c,d,e){return.5+.5*a.erf((b.log(c)-d)/b.sqrt(2*e*e))},inv:function(c,d,e){return b.exp(-1.4142135623730951*e*a.erfcinv(2*c)+d)},mean:function(a,c){return b.exp(a+c*c/2)},median:function(a,c){return b.exp(a)},mode:function(a,c){return b.exp(a-c*c)},sample:function(c,d){return b.exp(a.randn()*d+c)},variance:function(a,c){return(b.exp(c*c)-1)*b.exp(2*a+c*c)}}),a.extend(a.normal,{pdf:function(a,c,d){return b.exp(-0.5*b.log(2*b.PI)-b.log(d)-b.pow(a-c,2)/(2*d*d))},cdf:function(c,d,e){return.5*(1+a.erf((c-d)/b.sqrt(2*e*e)))},inv:function(b,c,d){return-1.4142135623730951*d*a.erfcinv(2*b)+c},mean:function(a,b){return a},median:function(a,b){return a},mode:function(a,b){return a},sample:function(b,c){return a.randn()*c+b},variance:function(a,b){return b*b}}),a.extend(a.pareto,{pdf:function(a,c,d){return a>c?d*b.pow(c,d)/b.pow(a,d+1):undefined},cdf:function(a,c,d){return 1-b.pow(c/a,d)},mean:function(a,c){return c>1?c*b.pow(a,c)/(c-1):undefined},median:function(a,c){return a*c*b.SQRT2},mode:function(a,b){return a},variance:function(a,c){return c>2?a*a*c/(b.pow(c-1,2)*(c-2)):undefined}}),a.extend(a.studentt,{pdf:function(c,d){return a.gammafn((d+1)/2)/(b.sqrt(d*b.PI)*a.gammafn(d/2))*b.pow(1+c*c/d,-((d+1)/2))},cdf:function(c,d){var e=d/2;return a.ibeta((c+b.sqrt(c*c+d))/(2*b.sqrt(c*c+d)),e,e)},inv:function(c,d){var e=a.ibetainv(2*b.min(c,1-c),.5*d,.5);return e=b.sqrt(d*(1-e)/e),c>0?e:-e},mean:function(a){return a>1?0:undefined},median:function(a){return 0},mode:function(a){return 0},sample:function(c){return a.randn()*b.sqrt(c/(2*a.randg(c/2)))},variance:function(a){return a>2?a/(a-2):a>1?Infinity:undefined}}),a.extend(a.weibull,{pdf:function(a,c,d){return a<0?0:d/c*b.pow(a/c,d-1)*b.exp(-b.pow(a/c,d))},cdf:function(a,c,d){return a<0?0:1-b.exp(-b.pow(a/c,d))},inv:function(a,c,d){return c*b.pow(-b.log(1-a),1/d)},mean:function(b,c){return b*a.gammafn(1+1/c)},median:function(a,c){return a*b.pow(b.log(2),1/c)},mode:function(a,c){return c>1?a*b.pow((c-1)/c,1/c):undefined},sample:function(a,c){return a*b.pow(-b.log(b.random()),1/c)},variance:function(c,d){return c*c*a.gammafn(1+2/d)-b.pow(this.mean(c,d),2)}}),a.extend(a.uniform,{pdf:function(a,b,c){return ac?0:1/(c-b)},cdf:function(a,b,c){return ae);return d-1}}),a.extend(a.triangular,{pdf:function(a,b,c,d){return c<=b||dc?undefined:ac?0:a<=d?2*(a-b)/((c-b)*(d-b)):2*(c-a)/((c-b)*(c-d))},cdf:function(a,c,d,e){return d<=c||ed?undefined:a(a+c)/2)return a+b.sqrt((c-a)*(d-a))/b.sqrt(2)},mode:function(a,b,c){return c},sample:function(a,c,d){var e=b.random();return e<(d-a)/(c-a)?a+b.sqrt(e*(c-a)*(d-a)):c-b.sqrt((1-e)*(c-a)*(c-d))},variance:function(a,b,c){return(a*a+b*b+c*c-a*b-a*c-b*c)/18}})}(this.jStat,Math),function(a,b){var d=Array.prototype.push,e=a.utils.isArray;a.extend({add:function(b,c){return e(c)?(e(c[0])||(c=[c]),a.map(b,function(a,b,d){return a+c[b][d]})):a.map(b,function(a){return a+c})},subtract:function(b,c){return e(c)?(e(c[0])||(c=[c]),a.map(b,function(a,b,d){return a-c[b][d]||0})):a.map(b,function(a){return a-c})},divide:function(b,c){return e(c)?(e(c[0])||(c=[c]),a.multiply(b,a.inv(c))):a.map(b,function(a){return a/c})},multiply:function(b,c){var d,f,g,h,i=b.length,j=b[0].length,k=a.zeros(i,g=e(c)?c[0].length:j),l=0;if(e(c)){for(;l=0;e--){j=0;for(f=e+1;f<=g-1;f++)j=k[f]*c[e][f];k[e]=(c[e][l-1]-j)/c[e][e]}return k},gauss_jordan:function(d,e){var f=a.aug(d,e),g=f.length,h=f[0].length;for(var i=0;ib.abs(f[j][i])&&(j=k);var l=f[i];f[i]=f[j],f[j]=l;for(var k=i+1;k=0;i--){c=f[i][i];for(var k=0;ki-1;m--)f[k][m]-=f[i][m]*f[k][i]/c;f[i][i]/=c;for(var m=g;mh?(j[g][h]=c[g][h],k[g][h]=l[g][h]=0):gf)m=p,p=a.add(a.multiply(o,m),n),g++;return p},gauss_seidel:function(c,d,e,f){var g=0,h=c.length,i=[],j=[],k=[],l,m,n,o,p;for(;gl?(i[g][l]=c[g][l],j[g][l]=k[g][l]=0):gf)m=p,p=a.add(a.multiply(o,m),n),g+=1;return p},SOR:function(c,d,e,f,g){var h=0,i=c.length,j=[],k=[],l=[],m,n,o,p,q;for(;hm?(j[h][m]=c[h][m],k[h][m]=l[h][m]=0):hf)n=q,q=a.add(a.multiply(p,n),o),h++;return q},householder:function(c){var d=c.length,e=c[0].length,f=0,g=[],h=[],i,j,k,l,m;for(;f0?-1:1,i=m*b.sqrt(i),j=b.sqrt((i*i-c[f+1][f]*i)/2),g=a.zeros(d,1),g[f+1][0]=(c[f+1][f]-i)/(2*j);for(k=f+2;k0?-1:1,l=o*b.sqrt(l),m=b.sqrt((l*l-c[g+1][g]*l)/2),h=a.zeros(e,1),h[g+1][0]=(c[g+1][g]-l)/(2*m);for(n=g+2;n=0;g--){p=0;for(k=g+1;k<=f-1;k++)p=j[k]*c[g][k];j[g]=d[g][0]/c[g][g]}return j},jacobi:function(c){var d=1,e=0,f=c.length,g=a.identity(f,f),h=[],i,j,k,l,m,n,o,p;while(d===1){e++,n=c[0][1],l=0,m=1;for(j=0;j0?b.PI/4:-b.PI/4:o=b.atan(2*c[l][m]/(c[l][l]-c[m][m]))/2,p=a.identity(f,f),p[l][l]=b.cos(o),p[l][m]=-b.sin(o),p[m][l]=b.sin(o),p[m][m]=b.cos(o),g=a.multiply(g,p),i=a.multiply(a.multiply(a.inv(p),c),p),c=i,d=0;for(j=1;j.001&&(d=1)}for(j=0;j=h)l=f(a,d+e),m=f(a,d),j[i]=(c[l]-2*c[m]+c[2*m-l])/(e*e),e/=2,i++;o=j.length,n=1;while(o!=1){for(p=0;pd)break;return g-=1,c[g]+(d-b[g])*m[g]+a.sq(d-b[g])*k[g]+(d-b[g])*a.sq(d-b[g])*n[g]},gauss_quadrature:function(){},PCA:function(b){var c=b.length,d=b[0].length,e=!1,f=0,g,h,i=[],j=[],k=[],l=[],m=[],n=[],o=[],p=[],q=[],r=[];for(f=0;f