liveBook · Manning

Relative standard deviation

As explained in Modern C

Relative standard deviation is the standard deviation divided by the mean, expressing dispersion relative to the average.

A noisy timing sample

Suppose repeated run times have a mean of 0.6 seconds and a standard deviation of 0.31 seconds. Their relative standard deviation is 0.31 / 0.6 ≈ 0.52, or 52%. The variation is substantial compared with the average. section 15.3

Relative standard deviation divides standard deviation by the mean, expressing variation relative to the average. A high value may signal a perturbed computation, unreliable measurements, or both. TAKEAWAY: Relative standard deviation of run times should be in a low percentage range; no fixed cutoff is given. section 15.3

Listing 15.3. Printing time statistics with stats_mean and stats_rsdev_unbiased
109     for (unsigned i = 0; i < loops; i++) {
110       double mean = stats_mean(&statistic[i]);
111       double rsdev  = stats_rsdev_unbiased(&statistic[i]);
112       printf("loop %u: E(t) (sec):\t%5.2e ± %4.02f%%,\tloop body %5.2e\n",
113              i, mean, 100.0*rsdev, mean/iterations);
114     }


!@%STYLE%@!
{"css":"{\"css\": \"font-weight: bold;\"}","target":"[[{\"line\":0,\"ch\":0},{\"line\":0,\"ch\":3}],[{\"line\":0,\"ch\":8},{\"line\":0,\"ch\":11}],[{\"line\":0,\"ch\":13},{\"line\":0,\"ch\":21}],[{\"line\":1,\"ch\":0},{\"line\":1,\"ch\":3}],[{\"line\":1,\"ch\":10},{\"line\":1,\"ch\":16}],[{\"line\":2,\"ch\":10},{\"line\":2,\"ch\":16}],[{\"line\":2,\"ch\":0},{\"line\":2,\"ch\":3}],[{\"line\":1,\"ch\":10},{\"line\":1,\"ch\":16}],[{\"line\":2,\"ch\":10},{\"line\":2,\"ch\":16}],[{\"line\":3,\"ch\":0},{\"line\":3,\"ch\":3}],[{\"line\":3,\"ch\":10},{\"line\":3,\"ch\":16}],[{\"line\":4,\"ch\":0},{\"line\":4,\"ch\":3}],[{\"line\":5,\"ch\":0},{\"line\":5,\"ch\":3}]]"}
!@%STYLE%@!

The C listing prints the mean beside 100 times the relative standard deviation, making the reported percentage visible alongside each loop’s run time. section 15.3

How Modern C covers it

How deep it goes
Defines the ratio, works a numerical case, and gives a qualitative low-percentage criterion without a fixed cutoff.
Examples
Calculates 0.31 / 0.6 ≈ 52% and shows C output reporting mean run time with a relative-deviation percentage.
What it assumes
Assumes basic familiarity with mean and standard deviation, advising a review of elementary statistics if needed.
What you can do after
Diagnose/debug with it by spotting run-time samples whose variation is substantial relative to their mean.
How it connects
Connects mean and standard deviation to performance measurement, alongside skew and raw moments.

Also explained in

Compare how 2 books explain relative standard deviation →

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