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 http://sourceware.org/cgi-bin/cvsweb.cgi/gsl/?cvsroot=gsl in statistics/covariance.c. -Jason _______________________________________________ pspp-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/pspp-dev
