<html>
<head>
<title>不確実性</title>
<script type="text/javascript">
function sample() {
var a,beta,ks,h,ls;
var s,m,mode,mx;
var k1,n1,n2,n3,c1,r1,l1,w1;
var ep,uc;
var maxc,minc;
var card;
k = new Array(101);
cx = new Array(101);
lx = new Array(101);
cm = new Array(101);
lm = new Array(101);
cms = new Array(101);
lms = new Array(101);
lxs = new Array(101);
cxs = new Array(101);
cps = new Array(101);
cp = new Array(101);
lp = new Array(101);
th =new Array(101);
chcx = new Array(101);
chlx = new Array(101);
chcm = new Array(101);
chlm = new Array(101);
for(m=1;m<101;m++){
th[m]=0.95+0.001*m;
}
for(m=1;m<101;m++){
cm[m]=0;
lm[m]=0;
}
a=0.33;
beta=0.95;
ls=(1-a)/(2-a);
ks=ls*Math.pow((1/ beta - 1)/a ,1/(a - 1));
h=2*ks/100;
for(s=1;s<101;s++){
k[s]=s*h;
}
for(s=1;s<101;s++){
lx[s]=ls;
cx[s]=Math.pow(k[s],a)*Math.pow(ls,1-a);
}
for(m=1;m<101;m++){
chcm[m]=0;
chlm[m]=0;
}
for(s=10;s<91;s++){
chcx[s]=0;
chlx[s]=0;
}
card=0;
while(card<100){
mode=0;
while(mode<10){
m=50;
for(s=10;s<91;s++){
l1=lx[s]+lm[m];
c1=cx[s]+cm[m]
k1=k[s]+th[m]*Math.pow(k[s],a)*Math.pow(l1,1-a)-c1;
n1=k1/h;
n2=Math.floor(n1);
n3=n2+1;
uc=0;
for(mx=1;mx<101;mx++){
c1=cx[n2]+(n1-n2)*(cx[n3]-cx[n2])+cm[mx];
l1=lx[n2]+(n1-n2)*(lx[n3]-lx[n2])+lm[mx];
r1=th[mx]*a*Math.pow(k1,a-1)*Math.pow(l1,1-a);
uc=uc+(beta*(1+r1))/c1;
}
uc=uc/100;
cxs[s]=1/uc-cm[m];
l1=lx[s]+lm[m];
w1=th[m]*(1-a)*Math.pow(k[s],a)*Math.pow(l1,-a);
lxs[s]=1-cx[s]/w1-lm[m];
}
ep=0;
for(s=10;s<91;s++){
ep=ep+(cx[s]-cxs[s])*(cx[s]-cxs[s])+(lx[s]-lxs[s])*(lx[s]-lxs[s]);
}
for(s=10;s<91;s++){
cx[s]=cxs[s];
lx[s]=lxs[s];
}
if(ep<0.0001)mode=1000;
mode=mode+1;
}
mode=0;
while(mode<10){
s=50;
for(m=1;m<101;m++){
l1=lx[s]+lm[m];
c1=cx[s]+cm[m]
k1=k[s]+th[m]*Math.pow(k[s],a)*Math.pow(l1,1-a)-c1;
n1=k1/h;
n2=Math.floor(n1);
n3=n2+1;
uc=0;
for(mx=1;mx<101;mx++){
c1=cx[n2]+(n1-n2)*(cx[n3]-cx[n2])+cm[mx];
l1=lx[n2]+(n1-n2)*(lx[n3]-lx[n2])+lm[mx];
r1=th[mx]*a*Math.pow(k1,a-1)*Math.pow(l1,1-a);
uc=uc+(beta*(1+r1))/c1;
}
uc=uc/100;
cms[m]=1/uc-cx[s];
l1=lx[s]+lm[m];
w1=th[m]*(1-a)*Math.pow(k[s],a)*Math.pow(l1,-a);
c1=cx[s]+cm[m];
lms[m]=1-c1/w1-lx[s];
}
ep=0;
for(m=1;m<101;m++){
ep=ep+(cm[m]-cms[m])*(cm[m]-cms[m])+(lm[m]-lms[m])*(lm[m]-lms[m]);
}
for(m=1;m<101;m++){
cm[m]=cms[m];
lm[m]=lms[m];
}
if(ep<0.0001)mode=1000;
mode=mode+1;
}
ep=0;
for(m=1;m<101;m++){
ep=ep+(cm[m]-chcm[m])*(cm[m]-chcm[m])+(lm[m]-chlm[m])*(lm[m]-chlm[m]);
}
for(s=10;s<91;s++){
ep=ep+(cx[s]-chcx[s])*(cx[s]-chcx[s])+(lx[s]-chlx[s])*(lx[s]-chlx[s]);
}
for(m=1;m<101;m++){
chcm[m]=cx[m];
chlm[m]=lx[m];
}
for(s=10;s<91;s++){
chcx[s]=cx[s];
chlx[s]=lx[s];
}
if(ep<0.0001)card=100;
card=card+1;
}
maxc=0;
for(s=10;s<91;s++){
if(lx[s]>maxc)maxc=lx[s];
}
minc=9999;
for(s=10;s<91;s++){
if(lx[s]<minc)minc=lx[s];
}
for(s=10;s<91;s++){
cps[s]=500*(lx[s]-minc)/(maxc-minc);
}
var canvas = document.getElementById('camp');
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.fillRect(100,100,3,500);
ctx.fillRect(100,600,500,3);
ctx.stroke();
ctx.beginPath();
for(s=1;s<101;s++){
ctx.fillRect(100+5*s,600-cps[s],3,3);
}
ctx.stroke();
}
</script>
</head>
<body onLoad="sample()">
<canvas id="camp" width="700" height="700">
</canvas>
</body>
</html>
最終更新:2013年09月17日 22:16