import java.awt.*;
class prob{
double[] ex(){
double p;
double mu;
double sig;
double yy;
double th[]= new double[101];
int s;
mu=0;
sig=0.39;
for (s=1;s<101;s++){
p=0.01*s-0.005;
yy=seeky(p,mu,sig);
th[s]=Math.exp(yy);
}
return th;
}
static double f(double x,double mu,double sig){
double pi,x1,x2,x3,fx;
pi = 3.1415;
x1=-Math.pow(x - mu,2) / (2*Math.pow(sig,2));
x2=Math.exp(x1);
x3=sig*Math.pow(2*pi,0.5);
fx=x2/x3;
return fx;
}
static double g(double y,double mu, double sig){
double gx,h,x;
int n,t;
gx=0;
h=0.001;
t=(int)(y/h);
for (n=-2000;n<t;n++){
x=n*h;
gx=gx+f(x,mu,sig)*h;
}
return gx;
}
static double seeky(double p,double mu,double sig){
double g1,g2,y1,y2,y3;
int t;
y1=0.4;
y2=-0.2;
g1=g(y1,mu,sig);
t=0;
while(t<100){
g2=g(y2,mu,sig);
y3=y2+(p-g2)*(y2-y1)/(g2-g1);
y1=y2;
y2=y3;
g1=g2;
if (Math.pow(p-g2,2)<0.0001)t=1000;
t=t+1;
}
return y2;
}
}
class Can extends Frame {
public static void main(String[] args) {
new CanvasTest();
}
Can() {
super("CanvasTest");
setSize(200, 100);
setLayout(new BorderLayout());
MyCanvas mc1 = new MyCanvas();
add(mc1, BorderLayout.CENTER);
show();
}
}
class MyCanvas extends Canvas {
public void paint(Graphics g) {
int thp[]=new int[101];
double th[]=new double[101];
int s;
prob ton =new prob();
th=ton.ex();
for (s=1;s<101;s++){
thp[s]=(int)(30*th[s]);
}
for (s=1;s<90;s++){
g.drawLine(s,thp[s], s+1,thp[s+1]);
}
}
}
最終更新:2009年12月18日 13:29