Covariance
Covariance is an unstandardized measure of how two random variables vary together relative to their means, indicating the direction of their linear association.
Causal Inference for Data Science
Covariance is a measure of the joint variation of two random variables.
- How it is used
- Connects joint variation to correlation, linear regression, causal diagrams, and instrumental-variable estimators.
- How deep it goes
- Defines algebraic identities and regression formulas, then applies them to causal graphs and instrumental variables without software implementation.
- Examples
- Uses confounder, mediator, and collider diagrams alongside regression calculations and an instrumental-variable covariance ratio.
- What you can do after
- Evaluate/understand covariance identities, interpret standardized correlations, and follow covariance-based regression and instrumental-variable calculations.
Read how Causal Inference for Data Science explains covariance →
Build a Robo-Advisor with Python (From Scratch)
Covariance is a measure of how two asset returns vary together, combining their volatilities with their correlation.
- How it is used
- Calculates portfolio volatility from asset weights and pairwise return relationships.
- How deep it goes
- Explains formulas, matrix construction, portfolio aggregation, and historical estimation, but defers sophisticated time-varying volatility methods.
- Examples
- Uses three-asset NumPy matrices, weighted portfolio volatility, and AAPL, FE, and WMT historical covariance estimates.
- What you can do after
- Apply covariance with NumPy or pandas to build covariance matrices and calculate portfolio standard deviation.
Read how Build a Robo-Advisor with Python (From Scratch) explains covariance →
Bayesian Optimization in Action
Covariance is a measure of how two random variables vary together.
- How it is used
- Uses covariance to jointly model multiple random variables with a multivariate Gaussian distribution.
- How deep it goes
- Defines covariance through matrix entries, distinguishing individual variances on the diagonal from pairwise relationships off the diagonal.
- Examples
- Uses a housing-price multivariate Gaussian and visualizations of samples, confidence intervals, and variable relationships.
- What you can do after
- Evaluate covariance matrices by identifying variable variances and pairwise relationships in multivariate Gaussian models.
Read how Bayesian Optimization in Action explains covariance →
Investing for Programmers
Covariance is a statistical measure of how two variables vary together, with positive values indicating movement in the same direction and negative values indicating opposite movement.
- How it is used
- Measures how asset returns move together when assessing relationships among investments in a portfolio.
- How deep it goes
- Defines covariance, demonstrates annualized calculation, and stops short of treating it as a strength measure.
- Examples
- Compares annualized covariance among Microsoft, Amazon, and Alphabet using return matrices and tables.
- What you can do after
- Apply it via pandas to calculate and interpret an annualized covariance matrix from asset log returns.
Data Without Labels
Covariance is a measure of how two variables vary together.
- How it is used
- Uses covariance as a Gaussian mixture parameter during probabilistic clustering.
- How deep it goes
- Defines covariance and places it in EM parameter updates, but does not develop its formula or numerical computation.
- Examples
- Uses a dataset of n items fitted with k Gaussian distributions and iteratively updated parameters.
- What you can do after
- Evaluate/understand covariance's role in fitting Gaussian mixture clusters through EM updates.
Related concepts
- correlationcontrasts with · Correlation is a statistical relationship describing how two or more variables or quantities vary together, including the strength and direction of their association, without by itself implying causation.
- Gaussian mixture modelused by · A Gaussian mixture model is a probabilistic model representing a distribution as a weighted combination of multiple Gaussian component distributions.
- Pearson correlation coefficientused by · The Pearson correlation coefficient measures the strength and direction of the linear relationship between two numerical variables.
- radial basis function kernelmeasured by · A radial basis function kernel is a similarity function whose value depends on the distance between inputs and typically decreases as that distance increases.
- instrumental variableused by · An instrumental variable is a variable that affects a treatment or exposure while influencing an outcome only through that treatment or exposure, under causal identifying assumptions.
- varianceuses · Variance is the expected squared deviation of a random variable from its mean, measuring the spread of its distribution.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.




