package network;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
public class pro {
int datanumber,number;
double[] beta=new double[11];
double alpha;
double[][] x=new double[101][11];
public static void main(String[] args) {
pro test=new pro();
}
pro(){
number=2;
x[1][1]=4;
x[1][2]=5;
beta[1]=3;
beta[2]=1;
alpha=2;
double e1=dist(1);
System.out.println(e1);
}
double dist(int n){
int s;
double z,k,zz,t,e;
double[] xs=new double[100];
z=0;
for(s=1;s<number+1;s++){
z=z+beta[s]*x[n][s];
}
k=this.alpha-z;
zz=0;
for(s=1;s<number+1;s++){
zz=zz+beta[s]*beta[s];
}
t=k/zz;
for(s=1;s<this.number+1;s++){
xs[s]=this.x[n][s]+t*beta[s];
}
e=0;
for(s=1;s<number+1;s++){
e=e+(this.x[n][s]-xs[s])*(this.x[n][s]-xs[s]);
}
return e;
}
}
最終更新:2016年12月03日 01:13