我正在尝试使用Apache Commons Math's SpearmansCorrelation,但由于我没有足够的数学/统计背景,我遇到了一些困难。
我研究过Spearman的秩相关性:
我找到了以下例子:
我想计算两个班级列表之间的相关性:
public class TestClass{
int rank; // there may be two or more classes with the same rank - will need an averaging ties strategy
}
我从中推断出以下内容:
NaturalRanking naturalRanking = new NaturalRanking(NaNStrategy.FIXED,
TiesStrategy.AVERAGE);
RealMatrix dataMatrix= createRealMatrix(double[], int, int); // what do I need this matrix for and what parameters do I need to pass?
SpearmansCorrelation sc = SpearmansCorrelation(dataMatrix, naturalRanking);
sc.correlation(double[],double[]);// I have to convert my class into a list of doubles? How?
答案 0 :(得分:2)
对于the link you provided中的示例,您需要做的只是:
new SpearmansCorrelation().correlation(mathsList,englishList);
默认情况下,班级将平均关系。