アットウィキロゴ

dart8766

import 'dart:html';
import 'dart:math';
 
void main() {
 
  dsge sub=new dsge();
  sub.makedata();
 
  querySelector("#sample");
 
 
}
 
class dsge{ 
 
double a,beta,ls,ks,h;
int n,t;
List k=new List(101);
List lx=new List(101);
List cx=new List(101);
List lxs=new List(101);
List cxs=new List(101);
double c1,l1,k1,r1,w1,ep;
double n1;
int n2,n3;
 
void makedata(){
 
a=0.33; 
beta=0.95; 
ls=(1-a)/(2-a); 
ks=ls*pow((1 / beta - 1) / a , 1 / (a - 1)) ; 
h=2*ks/100; 
for (n=1;n<101;n++){ 
k[n]=n*h; 
lx[n]=ls; 
cx[n]=pow(k[n],a)*pow(ls,1-a); 
} 
 
t=0; 
while(t<30){ 
for (n=10;n<91;n++){ 
k1=k[n]+pow(k[n],a)*pow(lx[n],1-a)-cx[n]; 
n1=k1/h; 
n2=n1.floor(); 
n3=n2+1; 
c1=cx[n2]+(n1-n2)*(cx[n3]-cx[n2]); 
l1=lx[n2]+(n1-n2)*(lx[n3]-lx[n2]); 
r1=a*pow(k1,a-1)*pow(l1,1-a); 
cxs[n]=c1/(beta*(1+r1)); 
w1=(1-a)*pow(k1,a)*pow(l1,-a); 
lxs[n]=1-cx[n]/w1; 
} 
 
ep=0.0; 
for (n=10;n<91;n++){ 
ep=ep+pow(cx[n]-cxs[n],2)+pow(lx[n]-lxs[n],2); 
} 
 
for (n=10;n<91;n++){ 
cx[n]=cxs[n]; 
lx[n]=lxs[n]; 
} 
 
if (ep<0.0001)t=1000;  
t=t+1; 
} 
 
 
}
}
最終更新:2013年11月20日 06:04