liveBook · Manning

Standard deviation

As explained in Experimentation for Engineers

A measure of the typical magnitude of deviations from a quantity's mean.

Standard deviation (SD) measures the typical magnitude of deviations from a quantity’s mean. For measurements with a known expectation, compute the square root of the mean squared deviations from that expectation. With black-box data, estimate the expectation with the sample mean: `sd = np.sqrt(((measurements - measurements.mean())**2).mean())`, or use `measurements.std()`. section 2.2.1

Execution-cost measurements

Three ASDAQ measurements are approximately 12.28, 10.15, and 12.62 mips. Their mean is 11.68, while individual deviations from the expectation of 12 mips reach 1.85; the mean is only 0.32 away. NumPy reports an individual-measurement SD of about 1.1. Repeating the experiment shows why aggregation helps: the SD of aggregate means falls from about 0.57 with 3 observations, to 0.18 with 30, and 0.058 with 300. section 2.2.1

Use standard deviation to quantify measurement variation and plan experiments:

  • Estimate the standard error of an aggregate mean as `se = sd_1 / np.sqrt(num_ind)`, where `sd_1` is the SD of individual measurements. section 2.2.1
  • Combine the individual-measurement variation from two exchanges as `sd_1_delta = np.sqrt(sd_1_asdaq**2 + sd_1_byse**2)` when designing an A/B test. section 2.3.2
  • Use the estimated variation with a practical significance threshold to choose enough observations for statistical significance; the example yields 7 observations without, or 16 with, power analysis. section 2.3.2
np.random.seed(17)
measurements = np.array([trading_system("ASDAQ") for _ in range(3)])
print(measurements) 
[[12.27626589 10.14537192 12.62390111]

Inspect the reproducible three-measurement NumPy example before generalizing to aggregate measurement and experiment design. section 2.2.1

How Experimentation for Engineers covers it

How deep it goes
Defines SD, works through deviations and aggregation, and extends it to standard error and power-based measurement planning.
Examples
Uses ASDAQ and BYSE execution-cost measurements, NumPy calculations, repeated aggregate simulations, and measurement-count design examples.
What it assumes
Assumes familiarity with means, deviations, square roots, NumPy arrays, and aggregate measurements.
What you can do after
Apply it via NumPy to quantify variation, estimate aggregate-measurement error, and design A/B-test sample sizes.
How it connects
Connects standard deviation with mean, standard error, aggregation, A/B testing, statistical significance, and power analysis.

Also explained in

Compare how 15 books explain standard deviation →

Related concepts

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