Calkuje gestosc prawdopodobienstwa normalnego let c=1/Math.sqrt(2*Math.PI), mi=3, sigma=2, dx=0.001, s=0 for (let x=mi-10*sigma; x 1)) { p=0.5} else if (p < p_low) { q = Math.sqrt(-2 * Math.log(p)); retVal = (((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1);} else if (p <= p_high){ q = p - 0.5; r = q * q; retVal = (((((a1 * r + a2) * r + a3) * r + a4) * r + a5) * r + a6) * q / (((((b1 * r + b2) * r + b3) * r + b4) * r + b5) * r + 1);} else { q = Math.sqrt(-2 * Math.log(1 - p)); retVal = -(((((c1 * q + c2) * q + c3) * q + c4) * q + c5) * q + c6) / ((((d1 * q + d2) * q + d3) * q + d4) * q + 1);} return retVal;} Calkuje gestosc prawdopodobienstwa normalnego 2D let r=0.9, c1=1/(2*Math.PI*Math.sqrt(1-r*r)), c2=-0.5/(1-r*r) let d=0.01, s=0 for (let x=-4; x<4; x+=d){ for (let y=-4; y<4; y+=d){ s+=c1*Math.exp(c2*(x*x-2*r*x*y+y*y)) }} s=s*d*d pisz(""+s+", ") Korelacja let n=100, m=10; for (let i=0; i"+r.toFixed(4))}; function rn(){let p=Math.random(), sig=1; if (p>0.5){p=1-p; sig=-1}; let c=[2.515517,0.802853,0.010328], d=[1.432788,0.189269,0.001308]; let t=Math.sqrt(Math.log(1/(p*p))); return sig*(t-((c[2]*t+c[1])*t+c[0])/(((d[2]*t+d[1])*t+d[0])*t+1))} Ekstremalne (do histogramu) n=10000 for (let i=0; imax){max=x}} x[i]=max} function rn(){let p=Math.random(), sig=1; if (p>0.5){p=1-p; sig=-1}; let c=[2.515517,0.802853,0.010328], d=[1.432788,0.189269,0.001308]; let t=Math.sqrt(Math.log(1/(p*p))); return sig*(t-((c[2]*t+c[1])*t+c[0])/(((d[2]*t+d[1])*t+d[0])*t+1))}