package blog;
import tool.*;
public class pro {
int s,datanumber;
String[] data=new String[5000];
String[][] subdata=new String[5000][10];
int[] point=new int[5000];
public static void main(String[] args) {
pro te=new pro();
}
pro(){
String str1="%20";
String id="1SJ94DEsnvhcSNHQcEP0XrgZkh-LD2PBJgRkGEv4z";
String urlx="https://www.googleapis.com/fusiontables/v1/query?sql=SELECT";
urlx=urlx+str1+"*"+str1+"FROM"+str1+id+str1;
urlx=urlx+"&key=AIzaSyAH0WCAXRIdHdbI-6bnMSN4kVDDZZmGyqY";
getdata sub=new getdata();
sub.makedata(urlx,"UTF-8");
data=sub.data;
datanumber=sub.datanumber;
String str="";
for(s=1;s<datanumber+1;s++){
str=str+data[s];
}
String[] x=str.split("],");
int sx;
for(s=1;s<x.length;s++){
x[s]=x[s].replace("[","");
String[] y=x[s].split(",");
for(sx=0;sx<y.length;sx++){
y[sx]=y[sx].replace("\"","");
y[sx]=y[sx].replace(" ","");
y[sx]=y[sx].replace("]]}","");
y[sx]=y[sx].replace("rows:","");
subdata[s][sx+1]=y[sx];
}
}
datanumber=x.length-1;
for(s=1;s<datanumber+1;s++){
point[s]=numx(subdata[s][2]);
}
int a1=0;
double a2=0;
for(s=1;s<datanumber+1;s++){
a1=a1+point[s];
a2=a2+point[s]*(50*s-25);
}
double mu= a2/a1;
double a4=0;
for(s=1;s<datanumber+1;s++){
a4=a4+point[s]*(50*s-25-mu)*(50*s-25-mu);
}
a4=a4/a1;
double sig=Math.sqrt(a4);
double k=mu+sig*randx();
if(k<0)k=0;
System.out.println(k);
}
int numx(String str){
int nx;
nx=0;
try{
nx=Integer.parseInt(str);
}catch (Exception e) {}
return nx;
}
double randx(){
double pi = Math.PI;
double x1=Math.random();
double x2=Math.random();
double f1=Math.log(x1);
double r=Math.sqrt(-2*f1)*Math.cos(2 * pi * x2);
return r;
}
}
最終更新:2016年03月14日 12:46