R2
xiahui1986 opened this issue · comments
xh commented
有没有返回R平方的值?
xcpro commented
不平方,R值也可以,望开放
xcpro commented
不平方,R值也可以,望开放
var n=data.length,sumxy=0,sumx=0,sumy=0,hypotx=0,hypoty=0;
for(let i=0;i<n;i++){
sumx+=data[i][0];
sumy+=data[i][1];
sumxy+=data[i][0]*data[i][1];
hypotx+=Math.pow(data[i][0],2);
hypoty+=Math.pow(data[i][1],2);
}
var r=(n*sumxy-sumx*sumy)/(Math.sqrt(n*hypotx-Math.pow(sumx,2))*Math.sqrt(n*hypoty-Math.pow(sumy,2)));
自己弄了个