Hi,

I'm trying to compute the correlation between two arrays and get a different 
value to what I get using Mathematica or even Excel.

This is part of my code, where ci and cj are 2 pointers to gsl vectors:

double correl;

gsl_vector_view mci = gsl_matrix_row(C, i);
gsl_vector_memcpy(ci, &mci.vector);

gsl_vector_view mcj = gsl_matrix_row(C, j);
gsl_vector_memcpy(cj, &mcj.vector);

correl = gsl_stats_correlation(ci->data, ci->stride, cj->data, cj->stride, 
NSONGS);

The two arrays / vectors are:

1 0 1 0 0 0 0 0 0 0 0 0 0 0 1
1 1 0 1 1 0 0 0 0 0 0 0 0 1 0

And the result for correl is  -9.58308e-21 when it 'should' be -1.96262e-17.

Am I doing something wrong?

Thanks in advance,
Martin

_______________________________________________
Bug-gsl mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/bug-gsl

Reply via email to