import java.awt.*;
import java.awt.event.*;
public class javadsge02 extends Frame{
public static void main(String[] args) {
javadsge02 f = new javadsge02();
f.setSize(500, 500);
f.setVisible(true);
f.addWindowListener(new Adap());
}
public void paint(Graphics g)
{
int s;
int x[]=new int[101];
double y[]=new double[101];
int z[]=new int[101];
dsge fun=new dsge();
y=fun.pro2();
for (s=1;s<100;s++){
x[s]=5*s;
z[s]=(int)(500-100*y[s]);
}
for (s=1;s<99;s++){
g.drawLine(x[s],z[s],x[s+1], z[s+1]);
}
}
}
class Adap extends WindowAdapter
{
public void windowClosing(WindowEvent e){
System.exit(0);
}
}
class dsge{
public double[] pro2(){
double a;
double beta;
double ks;
double h;
double k[]=new double[101];
double cx[][]=new double[11][101];
double cp[][]=new double[11][101];
double th[]=new double[11];
double k1;
double n1;
int n2;
int n3;
int n;
double c1;
double r1;
double ep;
int m;
int mx;
int t;
double uc;
double kt[]=new double[101];
double ct[]=new double[101];
a=0.33;
beta=0.95;
ks=Math.pow((1 / beta - 1) / a , 1 / (a - 1));
h=2*ks/100;
for (m=1;m<11;m++){
th[m]=1+0.01*m;
}
for (n=1;n<101;n++){
k[n]=n*h;
}
for (m=1;m<11;m++){
for (n=1;n<101;n++){
cx[m][n]=th[m]*Math.pow(k[n],a);
}
}
t=0;
while(t<100){
for (m=1;m<11;m++){
for (n=10;n<91;n++){
k1=k[n]+th[m]*Math.pow(k[n],a)-cx[m][n];
n1=k1/h;
n2=(int)n1;
n3=n2+1;
uc=0;
for (mx=1;mx<11;mx++){
c1=cx[mx][n2]+(n1-n2)*(cx[mx][n3]-cx[mx][n2]);
r1=th[mx]*a*Math.pow(k1,a-1);
uc=uc+(beta*(1+r1))/c1;
}
uc=0.1*uc;
cp[m][n]=1/uc;
}
}
ep=0;
for (m=1;m<11;m++){
for (n=10;n<91;n++){
ep=ep+Math.pow(cx[m][n]-cp[m][n],2);
}
}
for (m=1;m<11;m++){
for (n=10;n<91;n++){
cx[m][n]=cp[m][n];
}
}
if (ep<0.0001){
t=1000;
}
t=t+1;
}
kt[1]=k[45];
for (t=1;t<100;t++){
m=(int)(Math.random()*10)+1;
n1=kt[t]/h;
n2=(int)n1;
n3=n2+1;
ct[t]=cx[m][n2]+(n1-n2)*(cx[m][n3]-cx[m][n2]);
kt[t+1]=kt[t]+th[m]*Math.pow(kt[t],a)-ct[t];
}
return ct;
}
}
最終更新:2009年12月09日 08:52