PCCs系数

Posted developer-ios

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PCCs系数相关的知识,希望对你有一定的参考价值。

package ai;

public class pccs {

public static void main(String[] args) {
double same[][]=new double[2][4];
same[0]=new double[]{1,2,3,4,6,6,7,7,8,8,9};
same[1]=new double[]{-1,-2,-3,-4,-6,-6,-7,-7,-8,-8,-9};//{1,2,3,4,6,6,7,7,8,0,9};
double ship=sameShip(same);
System.out.println(ship);
}

public static double []sum(double same[][]){
double samesSum[]={0,0};
double sumA=0;
double sumB=0;
for(double entity:same[0]){
sumA+=entity;
}
for(double entity:same[1]){
sumB+=entity;
}
samesSum[0]=sumA;
samesSum[1]=sumB;
return samesSum;
}
public static double []squareSum(double same[][]){
double samesSum[]={0,0};
double sumA=0;
double sumB=0;
for(double entity:same[0]){
sumA+=(entity*entity);
}
for(double entity:same[1]){
sumB+=(entity*entity);
}
samesSum[0]=sumA;
samesSum[1]=sumB;
return samesSum;
}
public static double joinSum(double same[][]){
double joinSum=0;
for(int i=0;i<same[0].length;i++){
joinSum+=same[0][i]*same[1][i];
}
return joinSum;
}
public static double sameShip(double same[][]){
int num_ratings=same[0].length;
double product_sum= joinSum(same);
double sumTwo[]=sum(same);
double squareSumEntity[]=squareSum(same);
double user1_squared_sum=squareSumEntity[0];
double user2_squared_sum=squareSumEntity[1];
double Sxy=product_sum-(sumTwo[0]*sumTwo[1]/num_ratings);
double Sxx = user1_squared_sum - (sumTwo[0]*sumTwo[0]) / num_ratings;
double Syy = user2_squared_sum - (sumTwo[1]*sumTwo[1]) / num_ratings;
if (Sxx * Syy == 0)
return 0;

return Sxy / (Math.sqrt(Sxx * Syy));
}
}



























































以上是关于PCCs系数的主要内容,如果未能解决你的问题,请参考以下文章

如何理解皮尔逊相关系数

相关系数与决定系数的关系,它们的意义分别是啥

二项式系数的和与各项系数的和怎么求,公式?

决定系数啥意思?

什么是决定系数?

如何计算两变量的相关系数r?