help-gsl
[Top][All Lists]
Advanced

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

Re: [Help-gsl] Where oh where did the correlation cofficient go?


From: Jack Denman
Subject: Re: [Help-gsl] Where oh where did the correlation cofficient go?
Date: Thu, 31 May 2007 06:52:30 -0700

On Wed, 2007-05-30 at 11:27 +0100, Brian Gough wrote:

> At Fri, 25 May 2007 06:31:49 -0700,
> Jack Denman wrote:
> > I must have done something wrong. I created the results of an ideal
> > linear function of y = mx +b and did the regression on the values
> > and calculated the value of rho. I did this to check the accuracy of
> > my code. The answer was off by a factor of roughly fifty ( rho =
> > 0.02 ). I used both unweighted and neutrally weighted function
> > calls. Below is listed the results and the code.
> > Where did I go wrong?
> 
> Sorry, the formula I gave you had a typo, it should be
> cov01/sqrt(cov00*cov11).  Also, that gives the correlation of the fit
> parameters.  For the correlation of the data, which is what you want,
> you need to do:
> 
>   #include <gsl/gsl_statistics.h>
> 
>   cov01 = gsl_stats_covariance(x,1,y,1,n);
>   cov00 = gsl_stats_variance(x,1,n);
>   cov11 = gsl_stats_variance(y,1,n);
>   r=cov01/sqrt(cov00*cov11);


Thanks for the follow up. It's just what the doctor ordered.
-- 
Jack Denman <address@hidden>


reply via email to

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