From: Ben Pfaff Date: Wed, 14 Apr 2004 02:26:37 +0000 (+0000) Subject: Adjust calculation of kurtosis to avoid subtracting huge numbers from X-Git-Tag: v0.4.0~279 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e78d51c7941a26eef71d69260b49eeb1db954428;p=pspp-builds.git Adjust calculation of kurtosis to avoid subtracting huge numbers from huge numbers, on Michael Kiefte's advice. --- diff --git a/src/ChangeLog b/src/ChangeLog index 1fdf0d54..6db983d6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Tue Apr 13 19:24:15 2004 Ben Pfaff + + * moments.c (calc_moments): Adjust calculation of kurtosis to + avoid subtracting huge numbers from huge numbers, on Michael + Kiefte's advice. + Sun Apr 11 14:22:12 2004 Ben Pfaff Rework moments routines for improved numerical stability based on diff --git a/src/moments.c b/src/moments.c index c993f7ae..c4f3fe18 100644 --- a/src/moments.c +++ b/src/moments.c @@ -62,9 +62,9 @@ calc_moments (enum moment max_moment, } if (max_moment >= MOMENT_KURTOSIS && kurtosis != NULL && w > 3.) { - double g2 = ((w * (w + 1.) * d4 - - 3. * pow2 (d2) * (w - 1.)) - / ((w - 1.) * (w - 2.) * (w - 3.) * pow2 (s2))); + double den = (w - 2.) * (w - 3.) * pow2 (s2); + double g2 = (w * (w + 1) * d4 / (w - 1.) / den + - 3. * pow2 (d2) / den); if (finite (g2)) *kurtosis = g2; }