# standard deviation calculation using covariance?

i require a formula to calculate the standard deviation using variances of three or more variables (lets call them a,b,c) and the covariances between them. To complicate matters more i only need a percentage of all three totalling 100%, so for example a = 50%, b = 40% and c = 10%. Can anybody point me to the right direction as to how i can accomplish this please?

-
standard deviation of what? – wolfies Oct 10 '13 at 15:48

It looks as if you want the variance of $r X+s Y+tZ$, where $X$, $Y$, and $Z$ are random variables, and $r$, $s$, and $t$ are constants. (It so happens in your problem that $r+s+t=1$, but we will not be using that fact.) The required formula is $$\text{Var}(rX+sY+tZ)=r^2\text{Var}(X)+s^2\text{Var}(Y)+t^2\text{Var}(Z)+2rs\text{Cov}(X,Y)+2st\text{Cov}(Y,Z)+2tr\text{Cov}(Z,X).$$

For the standard deviation of $rX+sY+tZ$, take the square root of $\text{Var}(rX+sY+tZ)$ computed by the above formula.

Remark: The above formula can be derived from the definition of variance. The calculation is algebraically straightforward, but not particularly enlightening. I can write out some details if that would be helpful.

The formula can also be derived from the two-variable version of the formula, which may be familiar to you: $\text{Var}(cU+dV)=c^2\text{Var}(U)+d^2\text{Var}(V)+2cd\text{Cov}(U,V)$.

-
Hello Andre, thanks for your response, please forgive me for my ignorance, but lets say hypothetically the varX = 1.2 varY = 0.5 and varZ = 3.0 and we wanted 50%, 20% and 30% respectively. The covariance between xy is -1, yz = 2 and zx = 0. would the calculation be: (1.2 * (0.5 * 0.5)) + (0.5 * (0.2 * 0.2)) + (3.0 * (0.3 * 0.3)) + (2* -1) + (2 * 2) + (2 * 0) = 2.59? Thanks in advance! – godzilla Oct 10 '13 at 17:03
The variance terms were handled right, but not the covariance terms. Remember the $2rs\text{Cov}(X,Y)$. So we want $(2)(0.5)(0.2)(-1)$ for that term, not $(2)(-1)$, and similar corrections for the two other covariance terms. And then we take the square root for the standard deviation. – André Nicolas Oct 10 '13 at 17:12
brilliant thanks! This formula can be expanded for more than three variables correct? – godzilla Oct 10 '13 at 17:18
Yes, the "natural" generalization is correct. For the covariance terms for $\sum r_i X_i$, you use the sum over all $i\lt j$ of $2r_ir_j \text{Cov}(X_i,X_j)$. So for example there will be $6$ covariance terms for $4$ random variables, and $10$ for $5$ random variables. – André Nicolas Oct 10 '13 at 17:21
apologies Andre but for the covariance would the calculation be 2* (0.5 * 0.2 ) * -1 or 2 * 0.5 * 0.2 * -1? – godzilla Oct 14 '13 at 21:19