Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commons Maths : Pearsons Correlation returns NaN .

Tags:

java

I am calculating the correlation of two arrays.

x = {1,2,3};
y = {1,1,1};

The PearsonsCorrelation from apache commons math is returnin NaN for these arrays. i.e.

PearsonsCorrelation corr = new PearsonsCorrelation();
double result = corr.correlation(x, y); //result = NaN.

Why isn't the answer 0.0?

like image 544
h.i Avatar asked Jan 17 '12 13:01

h.i


1 Answers

The Pearson correlation may be thought of as the ratio of covariance of these series to the product of their standard deviations. The problem stems from the fact that the second series has standard deviation of 0.

like image 61
Sean Owen Avatar answered Oct 07 '22 07:10

Sean Owen