# Calculation of covariance given a joint probability function

CFA level I / Quantitative Methods: Basic Concepts / Probability Concepts / Calculation of covariance given a joint probability function

The joint probability function of two random variables, X and Y, denoted P(X, Y), gives the probability of joint occurrences of values of X and Y.

Joint probability function of returns of two stocks A and B

 RB=22 percent RB=14 percent RB=8 percent RA=18 percent 0.35 0 0 RA=12 percent 0 0.40 0 RA=6 percent 0 0 0.25

The expected return of the stock A from the above table = 0.35*0.18 + 0.40*0.12 + 0.25*0.06 = 12.6 percent

The expected return of the stock B from the above table = 0.35*0.22 + 0.40*0.14 + 0.25*0.08 = 15.3 percent

Calculation of covariance:

Cov(RA, RB) = E{[RA - E(RA)] [RB - E(RB)]} = * [RA - E(RA)] [RB - E(RB)] = 0.35*[(0.18-0.126)(0.22-0.153)] + 0.40*[(0.12-0.126)(0.14 -0.153)] + 0.25*[(0.06-0.126)(0.08-0.153)] = 0.002832

Var(RA) = E{[RA - E(RA)]2} = 0.35*(0.18-0.126)2 + 0.40*(0.12-0.126)2 + 0.25*(0.06-0.126)2 = 0.002124

Var(RB) = E{[RB - E(RB)]2}= 0.35*(0.22-0.153)2 + 0.40*(0.14-0.153)2 + 0.25*(0.08-0.153)2 = 0.003801

σ(RA) = √Var(RA) = √0.002124 = 0.0461 = 4.61 percent

σ(RB) = √Var(RB) = √0.003801 = 0.0617 = 6.17 percent

Corr(RA, RB) = Cov(RA, RB)/ σ(RA) σ(RB) = 0.002832/(0.0461)(0.0617) = 0.9967.

CFA Institute does not endorse, promote or warrant the accuracy or quality of products and services offered by Konvexity. CFA® and Chartered Financial Analyst® are registered trademarks owned by CFA Institute.