[Top][All Lists]

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

Re: moments.c

From: Jason Stover
Subject: Re: moments.c
Date: Wed, 21 Mar 2007 23:10:37 -0400
User-agent: Mutt/1.5.10i

On Wed, Mar 21, 2007 at 02:27:22PM -0700, Ben Pfaff wrote:
> If correlations and moments are separate, you can compute them in
> a single pass like this:
>         for each case C do:
>             moments1_add(C)
>             correlations_add(C)

But correlations_add() would need to know what happened in
moments1_add(). Otherwise its computations would be redundant because
it would have to compute the mean on its own.

Correlations depend on the means. Computing correlations requires
either computing the means first, then the correlation (meaning an
extra data pass), or using a special algorithm that computes both
simultaneously. Since the computations of correlations and means are
intertwined in a one-pass algorithm, I thought the computation of 
correlation should be in moments.c. If it isn't in moments.c, then
anyone who wants to compute correlations would have to do so by
writing their own functions to manipulate the moments struct in the
loop, or forgoing the use of moments.c and re-writing their own
functions to compute means.

An algorithm for computing correlations with one pass was recently
added to the GSL cvs repository. You can see it at in


reply via email to

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