huge numbers, on Michael Kiefte's advice.
+Tue Apr 13 19:24:15 2004 Ben Pfaff <blp@gnu.org>
+
+ * 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 <blp@gnu.org>
Rework moments routines for improved numerical stability based on
}
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;
}