# How to calculate standard deviation of function with two variables

I have the following:

• x is mean of X={4,6} and equals to 5 and standard deviation of X equals to 1.41
• y is mean of Y={3,9} and equals to 6 and standard deviation of Y equals to 4.24

How can I calculate the standard deviation of z which is equal to:

$$z=\frac{y-x}{x}100 = \frac{6-5}{5}100=20$$

• $z$ is a number: it has no standard deviation. Perhaps you are asking about the standard deviation of the random variable $100(Y-X)/X$? If so, you haven't provided enough information, because it's impossible to determine the degree of association of $X$ and $Y$. – whuber Aug 9 '17 at 20:27

Suppose you have quantities $a,b$ and their standard deviations are $\Delta a, \Delta b$. Then if $s=a+b$ or $s=a-b$ then $\Delta s = \sqrt{(\Delta a)^2+(\Delta b)^2}$.

And if $q = a/b$ then $\dfrac{\Delta q}{q} = \sqrt{\left(\dfrac{\Delta a}{a}\right)^2+\left(\dfrac{\Delta b}{b}\right)^2}$

Your problem involves only subtraction and division, so you should be able to apply these easily. Look up "propagation of uncertainty" for more information.

• This solution implicitly makes many strong assumptions, of which the foremost is that $a$ and $b$ are not correlated. At the least you should identify the important assumptions you are making. – whuber Aug 9 '17 at 20:28

Your $20$ is based on means, but since your function is non-linear it is unlikely to be the mean of $Z$

You need more information, as shown in these examples

• Consider $X$ taking the values $4$ and $6$ each with probability $\frac12$ and independently $Y$ taking the values $4.5$ and $7.5$ each with probability $\frac12$. Then for $Z=\frac{Y-X}{X} \times 100$, the expectation of $Z$ is $25$ and the standard deviation is about $40.5$

• Consider $X$ taking the values $0$ with probability $\frac1{26}$ and $5.2$ with probability $\frac{25}{26}$ and independently $Y$ taking the values $4.5$ and $7.5$ each with probability $\frac12$. Then for $Z=\frac{Y-X}{10} \times 100$, $Z$ does not have an expectation or standard deviation. Similar examples can produce very large expectations and standard deviations

If $X$ and $Y$ are normally distributed and independent with the parameters you state, then simulation may suggest something similar to my first example. This would be misleading: in fact the distribution of $Z$ has heavy tails and no moments, similar to my second example

• Hey Henry, thank you very much for your answer. After reading your answer it made me realise that I was not precise enough and that I made a mistake in asking my question. Now I edit it and fixed it. Please check now. – yuk Aug 9 '17 at 18:45
• It is still unclear (for example I do not see how you calculated your new standard deviations), but if $X$ and $Y$ can each take two possible values independently, then $Z$ can take four possible values and you can find the mean and standard deviation of $Z$ – Henry Aug 9 '17 at 18:59
• I calculated the standard deviations using the formula for Sample Standard Deviation. Just to explain what is what here: X elements are measurements of weight of the same object at time t0 and Y elements are also measurements of weight of the same object at time t0. z is the increase/decrease of weight. Hope this makes it a bit clearer. – yuk Aug 9 '17 at 19:41
• (+1) These are good points. In the first bullet, (1) you mean $Z=(Y-X)/X\times 100$ and (2) the standard deviation is not "about 40.5": it is exactly $\sqrt{4375/2}\approx 46.77$. – whuber Aug 9 '17 at 20:35
• @whuber: You are correct about $Z$. Perhaps my standard deviation calculations are hopeless, but on the numbers in my example in the first bullet point, I get $\sqrt{\frac{13125}{8}}$. Since then the question has been edited and I would now get $\sqrt{\frac{9375}{2}} \approx 68.465$ as the standard deviation of $Z$ – Henry Aug 9 '17 at 21:39