liveBook · Manning

Variance

As explained in Investing for Programmers

Variance is a statistical measure of the average squared deviation of observations from their mean.

Variance measures the average squared deviation of observations from their mean. In financial analysis, it summarizes how widely prices or returns fluctuate, but its squared units make it harder to interpret directly. section 3.4.2 section 7.2.2

Use variance with these practical distinctions:

  • Pair variance with standard deviation: standard deviation is the square root of variance and returns dispersion to the original units. section 3.4.2 section 7.2.2
  • Prefer returns rather than absolute share prices when comparing stocks; price levels do not provide a reliable performance comparison. section 7.2.2
  • Use variance for theoretical statistics and relative dispersion, while relying more often on standard deviation in practical analysis. section 7.2.2

Computing variance for returns

A pandas workflow aggregates mean, standard deviation, and variance from log returns: `summary = log_rets_2023.agg(["mean", "std", "var"]).T`. For 2023, the reported variance is 0.018214 for Coca-Cola, 0.039690 for Apple, and 0.639385 for NuScale, indicating much greater dispersion for NuScale. section 3.4.2 section 3.4.2

How Investing for Programmers covers it

How deep it goes
Defines squared deviation, contrasts variance with standard deviation, and demonstrates aggregation without deriving the formula or statistical theory.
Examples
Demonstrates variance with Python aggregations and 2023 log-return statistics for Apple, Coca-Cola, and NuScale.
What it assumes
Assumes familiarity with means and stock returns while contrasting simple returns with logarithmic returns for statistical analysis.
What you can do after
Apply variance through pandas aggregations and interpret it alongside standard deviation when comparing financial return dispersion.
How it connects
Connects variance to mean, standard deviation, log returns, correlation, covariance, and portfolio risk.

Also explained in

Compare how 19 books explain variance →

Related concepts

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