Apache Commons Math SpearmansCorrelation - How to use

I am trying to use Apache Commons Math's SpearmansCorrelation but I am having some difficulty as I do not have enough background in mathematics/statistics.

I have researched Spearman's Rank Correlation from:

I have found the following examples:

I would like to calculate the correlation between two lists of my class:

public class TestClass{
    int rank; // there may be two or more classes with the same rank - will need an averaging ties strategy
}

From which I have deduced the following:

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? 

Answers


For the example found in the link you provided, all you need to do is:

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

The class will average ties by default.


Need Your Help

How does an OpenGL program interface with different graphic cards

opengl graphics 3d driver gpu

From what I understand (correct me if I am wrong), the OpenGL api converts the function calls written by the programmer in the source code into the specific gpu driver calls of our graphic card. Th...

Query error SQL Compact Edition 3.5

c# sql visual-studio sql-server-ce

In my solution I have a local database and a database connect class with a GetQuery function. This function works good but for some reason, it won't handle the query as shown below. When I run a qu...