2012-04-11 69 views
1

我想使用Apache Commons Math's SpearmansCorrelation但我有一些困難,因爲我沒有足夠的數學/統計背景。Apache Commons Math 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? 

回答

2

對於在the link you provided中找到的示例,您只需要執行以下操作:

new SpearmansCorrelation().correlation(mathsList,englishList); 

默認情況下,該類將平均關係。