This is the mail archive of the
gsl-discuss@sourceware.org
mailing list for the GSL project.
Re: correlation coefficient
- From: Ben Klemens <klemens at hss dot caltech dot edu>
- To: Patrick Alken <patrick dot alken at colorado dot edu>,gsl-discuss at sourceware dot org
- Cc: gsl-discuss at sourceware dot org
- Date: Thu, 15 Mar 2007 15:18:31 -0800
- Subject: Re: correlation coefficient
- References: <20070315230643.GA3334@hippogriff.physics.drexel.edu>
> Is there any interest in putting a new function in the
> statistics area for calculating the Pearson correlation coefficient?
> I think this can be done safely in gsl by just using
>
> r = gsl_stats_covariance(x,y) / (gsl_stats_sd(x) * gsl_stats_sd(y))
>
> but it would be more efficient to calculate everything in 1 pass
> through the data and I believe there is a stable algorithm to do
> this (similar to how the mean/variance is calculated). This is
> such a common function for people who work with data so I think
> it'd be nice to have it in gsl :)
I've been working on a library of stats functions to complement
the GSL, so it naturally includes a correlation matrix
function (apop_correlation_matrix). The library home page is at
http://apophenia.info . There's an accompanying book whose home page
(this week) is at http://avocado.econ.jhu.edu/modeling .
Responding to your request for a covariance with an entire package may
be overkill, but I assume if you're looking for one statistic, you're
probably looking for several more.
Regards,
BK