liveBook · Manning

Raw moment

As explained in Modern C, Third Edition

A raw moment is the sum of a specified power of each value in a sample.

Accumulating measurements

For each measured value `s`, update the sums `m0 += 1; m1 += s; m2 += s*s;`. A measurement of 1.3 contributes 1, 1.3, and 1.69, respectively. section 16.4

The kth raw moment of a sample S is `m_k(S) = Σ(s^k)` over every value s in S. Thus m0 counts measurements, m1 sums their values, and m2 sums their squares. These are sums, not averages: the mean is m1/m0. Higher-order moments can also be used to compute statistics such as skew, which describes asymmetry. section 16.4

TAKEAWAY: Keep the moment sums needed for a statistic while collecting repeated measurements; divide by the sample count when a mean is required. section 16.4

How Modern C, Third Edition covers it

How deep it goes
Defines the general sum and interprets its first three orders, but does not derive formulas for every statistic.
Examples
Uses zeroth, first, and second moments alongside repeatedly timed C loops.
What it assumes
Assumes basic familiarity with statistical concepts while defining raw moments explicitly.
What you can do after
Apply it to accumulate sums of powers from measurements for later statistical calculations.
How it connects
Connects sample count, mean, skew, and repeated performance measurement.

Also explained in

Compare how 2 books explain raw moment →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C, Third Edition. The section links point to the parts of the book it draws on.