Find variance of random variable $W\cos\theta+L\sin\theta$ where $L,W,\theta$ are normal random variables. Uncertainty propagation problem.

262 Views Asked by At

I have three variables - these are length ($L$), width ($W$) and angle ($\theta$). Each has a known mean and variance. $\theta$ is independent, but $L$ and $W$ are correlated, and I know their covariance. I want to estimate the uncertainty in apparent size (see image) given by the equation $f=W \cos(\theta) + L \sin(\theta)$.

illustration of apparent size

If I consider $W\cos(\theta)$ in isolation, then maybe the variance of this part becomes: $$\sigma^2_{\text{term 1}} = W^2 \cos^2(\theta) \left[ \left( \frac {\sigma_L} {L} \right)^2 + \left( \frac {\sin(\theta) \sigma_{\theta}} {\cos(\theta)} \right)^2 \right],$$ because $\sigma_{L\theta}$ is zero, since they are uncorrelated.

If this is right, then the variance of the $L\sin(\theta)$ term in isolation would be:

$$\sigma^2_{\text{term 2}} = L^2 \sin^2(\theta) \left[ \left( \frac{\sigma_W}{W} \right)^2 + \left( \frac {\cos(\theta)\sigma_{\theta}} {\sin(\theta)} \right)^2 \right],$$

and maybe I can combine them like this: $$\sigma^2 = \sigma^2_{\text{term 1}} + \sigma^2_{\text{term 2}} + 2\sigma_{\text{term 1}}\sigma_{\text{term 2}},$$ but I only know the covariance $\sigma_{LW}$ so it feels like I am approaching this in the wrong way.

Any help would be greatly appreciated. Unfortunately I am an engineer and not a mathematician!

EDIT: $L,W,\theta$ are normally distributed random variables.

1

There are 1 best solutions below

0
On BEST ANSWER

Let $L$~$\mathcal{N}(\mu_L,\sigma^2_L)$ and $W$~$\mathcal{N}(\mu_W,\sigma^2_W)$ and $\theta$~$\mathcal{N}(\mu_\theta,\sigma^2_\theta)$ be normal random variables with covariance matrix $\mathbf{\Sigma}$. If the orientation $\theta$ of your object is independent of the random variable $LW$ corresponding to its area, then the variance of the random variable $Z=W\cos\theta+L\sin\theta$ is given by

$$ \sigma^2_Z = \sigma^2_{W\cos\theta} + \sigma^2_{L\sin\theta} + 2 \sigma_{W\cos\theta, L\sin\theta} $$

where

  • $\sigma^2_{W\cos\theta} = (\mu^2_W + \sigma^2_W) \frac{1}{2} (1 + e^{-2 \sigma^2_\theta} \cos 2\mu_\theta) - \mu^2_W e^{-\sigma^2_\theta} \cos^2\mu_\theta$ is the variance of the random variable $W\cos\theta$.
  • $\sigma^2_{L\sin\theta} = (\mu^2_L + \sigma^2_L) \frac{1}{2} (1 - e^{-2 \sigma^2_\theta} \cos 2\mu_\theta) - \mu^2_L e^{- \sigma^2_\theta} \sin^2\mu_\theta$ is the variance of the random variable $L\sin\theta$.
  • $2\sigma_{W\cos\theta, L\sin\theta} = (\sigma_{L,W} + \mu_W \mu_L) e^{-2 \sigma^2_\theta} \sin2\mu_\theta - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta$ is twice the covariance between random variables $W\cos\theta$ and $L\sin\theta$, and $\sigma_{L,W} = \sigma_{W,L}$ is the covariance between random variables $L$ and $W$.

Again, this holds if $\theta$ is independent of $LW$. Otherwise, if no further independence assumptions can be made, then

$$ 2\sigma_{W\cos\theta, L\sin\theta} = \langle WL \sin2\theta \rangle - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta $$

where $\langle WL\sin2\theta \rangle$ is the expectation of random variable $WL\sin2\theta$. I can think of two ways to solve it. For one,

$$ \langle WL \sin2\theta \rangle = \sigma_{LW,\sin2\theta} + (\sigma_{L,W} + \mu_W \mu_L)e^{-2 \sigma^2_\theta} \sin2\mu_\theta $$

where $\sigma_{LW,\sin2\theta}$ is the covariance between random variables $LW$ and $\sin2\theta$. Secondly, if $\sigma_{LW,\sin2\theta}$ is unknown, then

$$ \langle WL \sin2\theta \rangle = \iiint (WL \sin2\theta) f(W,L,\theta) dW dL d\theta $$

and $f(W,L,\theta)$ is the multivariate normal probability density function of random variables $W,L,\theta$. In other words,

$$ \langle WL \sin2\theta \rangle = \iiint (WL \sin2\theta) \Big( \frac{e^{ -\frac{1}{2} (\mathbf{x}-\mathbf{\mu})^T \mathbf{\Sigma}^{-1} (\mathbf{x}-\mathbf{\mu}) }}{\sqrt{(2\pi)^3 |\mathbf{\Sigma}|}} \Big) dW dL d\theta $$

where

  • $\mathbf{x} = [L,W,\theta]$ is a vector of the random variables $L,W,\theta$
  • $\mathbf{\mu} = [\mu_L, \mu_W, \mu_\theta]$ is a vector of the means of random variables $L,W,\theta$
  • $\mathbf{\Sigma}$ is your covariance matrix of the random variables $L,W,\theta$
  • $| \mathbf{\Sigma} |$ is the determinant of $\mathbf{\Sigma}$
  • $\mathbf{\Sigma}^{-1}$ is the inverse of $\mathbf{\Sigma}$
  • $(\mathbf{x}-\mathbf{\mu})^T$ is the transpose of the vector given by $\mathbf{x}-\mathbf{\mu}$

I'm not certain the above integral can be resolved analytically, and I don't know the actual values of the parameters you're working with, so I'm unable to compute it myself. However, this nasty integral should be simple enough for you to compute via Python, Matlab, etc. The details of all derivations are below...


Let $L$~$\mathcal{N}(\mu_L,\sigma^2_L)$ and $W$~$\mathcal{N}(\mu_W,\sigma^2_W)$ and $\theta$~$\mathcal{N}(\mu_\theta,\sigma^2_\theta)$ be normal random variables whose covariance matrix is

$$ \mathbf{\Sigma} = \begin{bmatrix} \sigma^2_L & \sigma_{L,W} & 0 \\ \sigma_{L,W} & \sigma^2_W & 0 \\ 0 & 0 & \sigma^2_\theta \end{bmatrix} $$

The variance of the random variable $Z=W\cos\theta+L\sin\theta$ is given by

$ \sigma^2_Z = \sigma^2_{W\cos\theta} + \sigma^2_{L\sin\theta} + 2 \sigma_{W\cos\theta, L\sin\theta} $

where

  • $\sigma^2_{W\cos\theta}$ is the variance of the random variable $W\cos\theta$
  • $\sigma^2_{L\sin\theta}$ is the variance of the random variable $L\sin\theta$
  • $\sigma_{W\cos\theta, L\sin\theta}$ is the covariance of the random variables $W\cos\theta$ and $L\sin\theta$

Hereafter, for any random variable $X$, I may denote the mean of $X$ as $\mu_X$ or $\langle X \rangle$. Now, for any random variables $X,Y$, we have $\sigma^2_{X} = \langle X^2 \rangle - \langle X \rangle ^2$ and $\sigma_{X,Y} = \langle XY \rangle -\langle X \rangle \langle Y \rangle$. So, we proceed by expanding the terms $\sigma^2_{W\cos\theta}, \sigma^2_{L\sin\theta},$ and $2\sigma_{W\cos\theta, L\sin\theta}$ as follows

$ \sigma^2_{W\cos\theta} = \langle (W\cos\theta)^2 \rangle - \langle W\cos\theta \rangle ^2 = \langle W^2\cos^2\theta \rangle - \langle W\cos\theta \rangle ^2 \\ \sigma^2_{L\sin\theta} = \langle (L\sin\theta)^2 \rangle - \langle L\sin\theta \rangle ^2 = \langle L^2\sin^2\theta \rangle - \langle L\sin\theta \rangle ^2 $ $ \begin{array}{ll} 2\sigma_{W\cos\theta, L\sin\theta} & = 2 \big( \langle W\cos\theta L\sin\theta \rangle - \langle W\cos\theta \rangle \langle L\sin\theta \rangle \big) \\ & = 2 \langle W\cos\theta L\sin\theta \rangle - 2 \langle W\cos\theta \rangle \langle L\sin\theta \rangle \end{array} $

Now, if $X,Y$ are independent random variables, then $f(X),g(Y)$ are independent random variables. Hence, we have independence between the following pairs of variables: $W$ and $\cos\theta$; $L$ and $\sin\theta$; $W^2$ and $\cos^2\theta$; and $L^2$ and $\sin^2\theta$. Moreover, if $X,Y$ are independent random variables, then $\langle XY \rangle = \langle X \rangle \langle Y \rangle$. Thus, we rewrite the above equations as follows

$ \sigma^2_{W\cos\theta} = \langle W^2 \rangle \langle \cos^2\theta \rangle - \big( \langle W \rangle \langle \cos\theta \rangle \big)^2 = \langle W^2 \rangle \langle \cos^2\theta \rangle - \langle W \rangle ^2 \langle \cos\theta \rangle ^2 \\ \sigma^2_{L\sin\theta} = \langle L^2 \rangle \langle \sin^2\theta \rangle - \big( \langle L \rangle \langle \sin\theta \rangle \big)^2 = \langle L^2 \rangle \langle \sin^2\theta \rangle - \langle L \rangle ^2 \langle \sin\theta \rangle ^2 \\ 2\sigma_{W\cos\theta, L\sin\theta} = 2 \langle WL\cos\theta\sin\theta \rangle - 2 \langle W \rangle \langle \cos\theta \rangle \langle L \rangle \langle \sin\theta \rangle $

Now, we solve for the following quantities:

  • $\langle L \rangle = \mu_L$ by definition of $L$~$\mathcal{N}(\mu_L,\sigma^2_L)$
  • $\langle W \rangle = \mu_W$ by definition of $W$~$\mathcal{N}(\mu_W,\sigma^2_W)$
  • $\langle L^2 \rangle = \mu^2_L + \sigma^2_L$ as determined by the moment generating function (MGF) of $L$~$\mathcal{N}(\mu_L,\sigma^2_L)$
  • $\langle W^2 \rangle = \mu^2_W + \sigma^2_W$ as determined by the MGF of $W$~$\mathcal{N}(\mu_W,\sigma^2_W)$
  • $\langle \sin\theta \rangle = e^{-\frac{1}{2} \sigma^2_\theta} \sin\mu_\theta$ per Euler's formula $e^{i\theta} = \cos\theta + i \sin\theta$ where $i=\sqrt{-1}$. After taking the expectation of the equation, we obtain $\langle e^{i\theta} \rangle = \langle \cos\theta \rangle + i \langle \sin\theta \rangle$ where $\langle e^{i\theta} \rangle = e^{\frac{1}{2} \sigma^2_\theta i^2 + i\mu_\theta}$ corresponds to the MGF of $\theta$~$\mathcal{N}(\mu_\theta,\sigma^2_\theta)$ and $e^{\frac{1}{2} \sigma^2_\theta i^2 + i\mu_\theta} = e^{\frac{1}{2} \sigma^2_\theta \sqrt{-1}^2} e^{i\mu_\theta} = e^{-\frac{1}{2} \sigma^2_\theta} (\cos\mu_\theta + i\sin\mu_\theta)$. So, by substitution we have $e^{-\frac{1}{2} \sigma^2_\theta} \cos\mu_\theta + i e^{-\frac{1}{2} \sigma^2_\theta} \sin\mu_\theta = \langle \cos\theta \rangle + i \langle \sin\theta \rangle$, implying $\langle \sin\theta \rangle = e^{-\frac{1}{2} \sigma^2_\theta} \sin\mu_\theta$.
  • $\langle \cos\theta \rangle = e^{-\frac{1}{2} \sigma^2_\theta} \cos\mu_\theta$ because $e^{-\frac{1}{2} \sigma^2_\theta} \cos\mu_\theta + i e^{-\frac{1}{2} \sigma^2_\theta} \sin\mu_\theta = \cos\theta + i \sin\theta$ (see above).
  • $\langle \sin^2\theta \rangle = \frac{1}{2} (1 - e^{-2 \sigma^2_\theta} \cos 2\mu_\theta)$ per the double angle formula $\sin^2\theta = \frac{1-\cos2\theta}{2}$ and Euler's formula stated as $e^{i2\theta} = \cos2\theta + i \sin2\theta$. After taking the expectation of both equations, we have $\langle \sin^2\theta \rangle = \frac{1-\langle \cos2\theta \rangle}{2}$ and $\langle e^{i2\theta} \rangle = \langle \cos2\theta \rangle + i \langle \sin2\theta \rangle$. Note $\langle e^{i2\theta} \rangle = e^{\frac{1}{2} 4\sigma^2_\theta i^2 + i2\mu_\theta}$ corresponds to the MGF of $2\theta$~$\mathcal{N}(2\mu_\theta,4\sigma^2_\theta)$ resulting in the equation $e^{-2 \sigma^2_\theta} \cos2\mu_\theta + i e^{-2 \sigma^2_\theta} \sin2\mu_\theta = \langle \cos2\theta \rangle + i \langle \sin2\theta \rangle$, implying $\langle \cos2\theta \rangle = e^{-2 \sigma^2_\theta} \cos2\mu_\theta$. Hence, we have $\langle \sin^2\theta \rangle = \frac{1-\langle \cos2\theta \rangle}{2} = \frac{1-e^{-2 \sigma^2_\theta} \cos2\mu_\theta}{2} = \frac{1}{2} (1 - e^{-2 \sigma^2_\theta} \cos 2\mu_\theta)$.
  • $\langle \cos^2\theta \rangle = \frac{1}{2} (1 + e^{-2 \sigma^2_\theta} \cos 2\mu_\theta)$ due to the double angle formula $\cos^2\theta = \frac{1+\cos2\theta}{2}$ and the equation $e^{-2 \sigma^2_\theta} \cos2\mu_\theta + i e^{-2 \sigma^2_\theta} \sin2\mu_\theta = \langle \cos2\theta \rangle + i \langle \sin2\theta \rangle$ derived above. Hence, we have $\langle \cos^2\theta \rangle = \frac{1+\langle \cos2\theta \rangle}{2} = \frac{1+e^{-2 \sigma^2_\theta} \cos2\mu_\theta}{2} = \frac{1}{2} (1 + e^{-2 \sigma^2_\theta} \cos 2\mu_\theta)$.

After substituting the above quantities, we have

$ \begin{array}{ll} \sigma^2_{W\cos\theta} & = (\mu^2_W + \sigma^2_W) \frac{1}{2} (1 + e^{-2 \sigma^2_\theta} \cos 2\mu_\theta) - \mu^2_W (e^{-\frac{1}{2} \sigma^2_\theta} \cos\mu_\theta)^2 \\ & = (\mu^2_W + \sigma^2_W) \frac{1}{2} (1 + e^{-2 \sigma^2_\theta} \cos 2\mu_\theta) - \mu^2_W e^{-\sigma^2_\theta} \cos^2\mu_\theta \end{array} $ $ \begin{array}{ll} \sigma^2_{L\sin\theta} & = (\mu^2_L + \sigma^2_L) \frac{1}{2} (1 - e^{-2 \sigma^2_\theta} \cos 2\mu_\theta) - \mu^2_L (e^{-\frac{1}{2} \sigma^2_\theta} \sin\mu_\theta)^2 \\ & = (\mu^2_L + \sigma^2_L) \frac{1}{2} (1 - e^{-2 \sigma^2_\theta} \cos 2\mu_\theta) - \mu^2_L e^{- \sigma^2_\theta} \sin^2\mu_\theta \end{array} $ $ \begin{array}{ll} 2\sigma_{W\cos\theta, L\sin\theta} & = 2 \langle WL\cos\theta\sin\theta \rangle - 2 \mu_W (e^{-\frac{1}{2} \sigma^2_\theta} \cos\mu_\theta) \mu_L (e^{-\frac{1}{2} \sigma^2_\theta} \sin\mu_\theta) \\ & = 2 \langle WL\cos\theta\sin\theta \rangle - 2 \mu_W \mu_L e^{-\sigma^2_\theta} \cos\mu_\theta \sin\mu_\theta \\ & = 2 \langle WL\cos\theta\sin\theta \rangle - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta \\ & = \langle WL 2 \cos\theta\sin\theta \rangle - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta \\ & = \langle WL \sin2\theta \rangle - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta \end{array} $

Now, if the orientation $\theta$ of your object is independent of the random variable $LW$ corresponding to its area, then we can resolve $\langle WL \sin2\theta \rangle = \langle WL \rangle \langle \sin2\theta \rangle$ quite easily. For any random variables $X,Y$, we have $\sigma_{X,Y} = \sigma_{Y,X} = \langle XY \rangle - \langle X \rangle \langle Y \rangle$, which implies $\langle XY \rangle = \sigma_{X,Y} + \langle X \rangle \langle Y \rangle$. Thus, $\langle WL \rangle = \sigma_{L,W} + \langle W \rangle \langle L \rangle = \sigma_{L,W} + \mu_W \mu_L$. Furthermore, we have $\langle \sin2\theta \rangle = e^{-2 \sigma^2_\theta} \sin2\mu_\theta$ because $e^{-2 \sigma^2_\theta} \cos2\mu_\theta + i e^{-2 \sigma^2_\theta} \sin2\mu_\theta = \langle \cos2\theta \rangle + i \langle \sin2\theta \rangle$ (derived above). Therefore,

$\langle WL \sin2\theta \rangle = \langle WL \rangle \langle \sin2\theta \rangle = (\sigma_{L,W} + \mu_W \mu_L) e^{-2 \sigma^2_\theta} \sin2\mu_\theta$

and we have

$ \begin{array}{ll} 2\sigma_{W\cos\theta, L\sin\theta} & = (\sigma_{L,W} + \mu_W \mu_L) e^{-2 \sigma^2_\theta} \sin2\mu_\theta - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta \end{array} $

Otherwise, if no further independence assumptions can be made, then you can reapply the above reasoning to derive

$ \langle WL \sin2\theta \rangle = \sigma_{LW,\sin2\theta} + (\sigma_{L,W} + \mu_W \mu_L)e^{-2 \sigma^2_\theta} \sin2\mu_\theta $

and obtain

$ \begin{array}{ll} 2\sigma_{W\cos\theta, L\sin\theta} & = \sigma_{LW,\sin2\theta} + (\sigma_{L,W} + \mu_W \mu_L)e^{-2 \sigma^2_\theta} \sin2\mu_\theta - \mu_W \mu_L e^{-\sigma^2_\theta} \sin2\mu_\theta \end{array} $

where $\sigma_{LW,\sin2\theta}$ is the covariance between random variables $LW$ and $\sin2\theta$. If you don't know $\sigma_{LW,\sin2\theta}$, then you have to compute the expectation of $WL\sin2\theta$ as a triple integral via some statistical software as I'm not sure it can be decomposed analytically.