bug-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug-gsl] gsl_stats_correlation bug?


From: Schleicher, Martin
Subject: [Bug-gsl] gsl_stats_correlation bug?
Date: Tue, 17 Nov 2009 16:32:53 -0500

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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]