Commons Maths: Pearsons Correlation returns NaN.

I calculate the correlation of two arrays.

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

The PearsonsCorrelation of apache commons math returns for NaN for these arrays. i.e.

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

Why not answer 0.0?

+4
source share
1 answer

Pearson correlation can be considered as the ratio of the covariance of these series to the product of their standard deviations. The problem is that the second series has a standard deviation of 0.

+8
source

Source: https://habr.com/ru/post/1391443/


All Articles