+Mon Feb 5 15:42:14 2007 Ben Pfaff <blp@gnu.org>
+
+ * moments.c (moments_pass_two): Reduce number of multiplications.
+
Thu Dec 7 15:27:49 WST 2006 John Darrington <john@darrington.wattle.id.au>
* factor-stats.c factor-stats.h: Changed independent values to
void
moments_pass_two (struct moments *m, double value, double weight)
{
- double d, d_power;
-
assert (m != NULL);
if (m->pass == 1)
if (value != SYSMIS && weight >= 0.)
{
- m->w2 += weight;
-
- d = d_power = value - m->mean;
- m->d1 += d_power * weight;
-
+ double d = value - m->mean;
+ double d1_delta = d * weight;
+ m->d1 += d1_delta;
if (m->max_moment >= MOMENT_VARIANCE)
{
- d_power *= d;
- m->d2 += d_power * weight;
-
+ double d2_delta = d1_delta * d;
+ m->d2 += d2_delta;
if (m->max_moment >= MOMENT_SKEWNESS)
{
- d_power *= d;
- m->d3 += d_power * weight;
-
+ double d3_delta = d2_delta * d;
+ m->d3 += d3_delta;
if (m->max_moment >= MOMENT_KURTOSIS)
{
- d_power *= d;
- m->d4 += d_power * weight;
+ double d4_delta = d3_delta * d;
+ m->d4 += d4_delta;
}
}
}
+ m->w2 += weight;
}
}