アットウィキロゴ

tjk88

package c2;
 
 
public class pro {
 
   int[] point=new int[100];
     int[] pointx=new int[100];
    double[] avg=new double[101];
 
     double[] p=new double[11];
    double[] mu=new double[11];
    double[] sig=new double[11];
 int datanumber,number;
 
 
      double[] ps=new double[11];
    double[] mus=new double[11];
    double[] sigs=new double[11];
 
    double[][] q=new double[31][11];
    public static void main(String[] args) {
       pro r=new pro();
    }
 
 
    pro(){
 
 
       int s,sx; 
   point[	1	]=1351	;
point[	2	]=	296	;
point[	3	]=	265	;
point[	4	]=	227	;
point[	5	]=	238	;
point[	6	]=	209	;
point[	7	]=	197	;
point[	8	]=	169	;
point[	9	]=	183	;
point[	10	]=	149	;
point[	11	]=	164	;
point[	12	]=	133	;
point[	13	]=	136	;
point[	14	]=	125	;
point[	15	]=	141	;
point[	16	]=	124	;
point[	17	]=	99	;
point[	18	]=	89	;
point[	19	]=	61	;
point[	20	]=	60	;
point[	21	]=	410	;
 
 
pointx[	1	]=	54	;
pointx[	2	]=	205	;
pointx[	3	]=	339	;
pointx[	4	]=	380	;
pointx[	5	]=	407	;
pointx[	6	]=	385	;
pointx[	7	]=	358	;
pointx[	8	]=	336	;
pointx[	9	]=	298	;
pointx[	10	]=	265	;
pointx[	11	]=	223	;
pointx[	12	]=	234	;
pointx[	13	]=	191	;
pointx[	14	]=	168	;
pointx[	15	]=	157	;
pointx[	16	]=	133	;
pointx[	17	]=	93	;
pointx[	18	]=	89	;
pointx[	19	]=	86	;
pointx[	20	]=	77	;
pointx[	21	]=	348	;
 
 
 
 avg[	1	]=	270	;
avg[	2	]=	265.9	;
avg[	3	]=	311.9	;
avg[	4	]=	317.3	;
avg[	5	]=	351.2	;
avg[	6	]=	357.7	;
avg[	7	]=	395.9	;
avg[	8	]=	424.1	;
avg[	9	]=	457.5	;
avg[	10	]=	483.8	;
avg[	11	]=	572.2	;
avg[	12	]=	569.3	;
avg[	13	]=	608.9	;
avg[	14	]=	677.7	;
avg[	15	]=	691.8	;
avg[	16	]=	702.8	;
avg[	17	]=	769.8	;
avg[	18	]=	812	;
avg[	19	]=	839	;
avg[	20	]=	884.1	;
avg[	21	]=	1193.40	;
 
 datanumber=21;
 number=10;
 
  for(sx=1;sx<number+1;sx++){  
  mu[sx]=100*sx;
  sig[sx]=50;
  p[sx]=0.1;
  }
 
 double[][] rate=new double[24][11];
  int tr;
  double[] p1=new double[24];
 
  for(tr=1;tr<datanumber+1;tr++){
 
  int y1=50*tr-50;
 
  int y2=y1+50;
  if(tr>20)y2=1400;
 
for(s=1;s<number+1;s++){
int y;
p1[s]=0;
for(y=y1;y<y2;y++){
p1[s]=p1[s]+f(y,mu[s],sig[s])/(y2-y1);
}
}
double p2=0;
for(s=1;s<number+1;s++){
p2=p2+p1[s];
}
for(s=1;s<number+1;s++){
rate[tr][s]=p1[s]/p2;
}
 
}
 
 for(s=1;s<number+1;s++){
 
      double a1=0;
      double a2=0;
      double a3=0;
for(sx=1;sx<datanumber+1;sx++){
 int y1=50*sx-50;
 int y2=y1+50;
if(sx>20)y2=1400;
int y;
for(y=y1;y<y2;y++){ 
a1=a1+point[sx]*rate[sx][s]/(y2-y1);
a2=a2+y*point[sx]*rate[sx][s]/(y2-y1);      
}
}
if(a1>0)mu[s]=a2/a1;
for(sx=1;sx<datanumber+1;sx++){
 int y1=50*sx-50;
 int y2=y1+50;
if(sx>20)y2=1400;
int y;
for(y=y1;y<y2;y++){ 
a3=a3+(y-mu[s])*(y-mu[s])*point[sx]*rate[sx][s]/(y2-y1);      
}
}
if(a1>0)sig[s]=Math.sqrt(a3/a1);
}
 
  double p4=0;
  for(sx=1;sx<datanumber+1;sx++){
  p4=p4+point[sx];
  }
 
 for(s=1;s<number+1;s++){
 double a5=0;
 for(sx=1;sx<datanumber+1;sx++){
 a5=a5+point[sx]*rate[sx][s];
  }    
 p[s]=a5/p4;   
 }
 
 
 System.out.println(p[6]+","+mu[6]+","+sig[6]);
 
 
 
 
    }
 double f(double x,double mup,double sigp){
double pi,f1,f2;
 
        pi=Math.PI;
 
        f2=Math.sqrt(2*pi*sigp*sigp);
        f1=-(x-mup)*(x-mup)/(2*sigp*sigp);
 
        return Math.exp(f1)/f2;
}
 
}
最終更新:2017年01月13日 15:52