var th=new Array();
var ths=new Array();
var x=new Array();
var c=new Array();
var sig;
var point=new Array();
var p=new Array();
var d=new Array();
function sample(){
sig=10;
for(s=1;s<101;s++){
ths[s]=40+20*Math.random();
}
for(s=1;s<101;s++){
th[s]=s;
}
x[1]=50;
x[2]=46;
x[3]=47;
x[4]=60;
x[5]=51;
x[6]=52;
x[7]=55;
x[8]=45;
x[9]=51;
x[10]=52;
for(tr=1;tr<101;tr++){
c[tr]=new Array();
}
for(tr=1;tr<101;tr++){
for(s=1;s<101;s++){
c[tr][s]=0;
}
for(s=1;s<10001;s++){
x1=randx(ths[tr],sig);
x2=Math.floor(x1);
if(x2>100)x2=100;
if(x2<0)x2=0;
c[tr][x2]=c[1][x2]+1;
}
}
for(tr=1;tr<101;tr++){
z=1;
for(s=1;s<11;s++){
x3=x[s];
z=z*c[tr][x3];
}
point[tr]=z;
}
p1=0;
for(s=1;s<101;s++){
p1=p1+point[s];
}
for(s=1;s<101;s++){
point[s]=100*point[s]/p1;
}
var timer;
var delay = 1000;
var loop = function () {
sx=th[1];
p[1]=point[sx];
for(s=2;s<101;s++){
sx=th[s];
p[s]=p[s-1]+point[sx];
}
for(tr=1;tr<101;tr++){
m1=p[100]*Math.random();
sx=1;
for(s=2;s<101;s++){
if(m1>p[s])sx=s+1;
}
th[tr]=sx;
}
for(s=1;s<100;s++){
d[s]=0;
}
for(tr=1;tr<101;tr++){
s=th[tr];
m1=ths[s];
m2=Math.floor(m1);
if(m2<10)m2=10
if(m2>90)m2=90;
d[m2]=d[m2]+1;
}
paint();
clearTimeout(timer);
timer = setTimeout(loop, delay);
}
loop();
}
function randx(mu,sig) {
pi = Math.PI;
p1 = 0;
p2 = 0;
x1=Math.random();
x2=Math.random();
f1=Math.log(x1);
r=Math.sqrt(-2*f1)*Math.cos(2 * pi * x2);
p3=mu+sig*r;
return p3;
}
function paint(){
var sub=new svgpaint();
str="<svg width=\"700\" height=\"700\">";
for(s=1;s<101;s++){
str=str+sub.rect(5*s,500-30*d[s],5,30*d[s],"blue");
}
str=str+"</svg>";
$("#memo").html(str);
}
最終更新:2016年04月21日 20:29