我正在尝试使用Apache Commons Math 的 SpearmansCorrelation,但我遇到了一些困难,因为我没有足够的数学/统计学背景。
我从以下方面研究了 Spearman 的等级相关性:
- https://statistics.laerd.com/statistical-guides/spearmans-rank-order-correlation-statistical-guide-2.php
- http://geographyfieldwork.com/SpearmansRank.htm
我找到了以下示例:
- http://www.devdaily.com/java/jwarehouse/commons-math/src/main/java/org/apache/commons/math/stat/correlation/SpearmansCorrelation.java.shtml
- http://www.devdaily.com/java/jwarehouse/commons-math/src/test/java/org/apache/commons/math/stat/correlation/SpearmansRankCorrelationTest.java.shtml
- http://www.androidadb.com/class/na/NaturalRanking.html
我想计算我班级的两个列表之间的相关性:
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?