Ellipse Equation of 2D Gaussian Contour

348 Views Asked by At

Suppose I have a 2D Gaussian $f(x,y) = \mathcal{N}(x,y \mid \mu, \Sigma)$ with non-identity covariance matrix $$ \Sigma = \begin{pmatrix} \sigma_x^2 & \rho \\ \rho & \sigma_y^2 \end{pmatrix} $$ I would like to find the cartesian equation of the ellipse of a contour $f(x, y) = z$, for $z$ known.

My Attempt

I wrote the 2D Gaussian as $$ C = \frac{\overline{x}^2}{\sigma_x^2} - 2\rho \overline{x}\overline{y} + \frac{\overline{y}^2}{\sigma_y^2} $$

where $C = -2(1-\rho)\log(2\pi\sigma_x\sigma_y\sqrt{1 - \rho^2}z)$ and $\overline{x} = x-\mu_x$ and $\overline{y}=y-\mu_y$.

I compared this against what I think is the equation of a rotated ellipse $$ \overline{x}^2\left(\frac{\cos^2\theta}{a^2}+\frac{\sin^2\theta}{b^2}\right) - 2\overline{x}\overline{y}\cos\theta\sin\theta\left(\frac{1}{a^2}-\frac{1}{b^2}\right) + \overline{y}^2\left(\frac{\sin^2\theta}{a^2} + \frac{\cos^2\theta}{b^2}\right) $$

What is the best way of doing this for a given value of $z$? There must be some eigendecomposition trickery. I basically want to get $a,b,\theta$.

Attempt 2.0

Write the 2D Gaussian as $$ ({\bf{x}} - \boldsymbol{\mu})^\top \Sigma^{-1} ({\bf{x}} - \boldsymbol{\mu}) = \log\left(\frac{1}{4\pi^2\sigma_x^2\sigma_y^2(1 - \rho^2)z^2}\right) $$ And by calling $\gamma$ the constant on the RHS we divide by it on both sides and obtain $$ ({\bf{x}} - \boldsymbol{\mu})^\top \widetilde{\Sigma}^{-1} ({\bf{x}} - \boldsymbol{\mu}) = 1 $$ where $$ \widetilde{\Sigma}^{-1} = \frac{1}{\gamma}\Sigma^{-1} = \left(\gamma\Sigma\right)^{-1} $$ This is apparently the equation of an ellipsoid which would mean that eigenvalues of $\widetilde{\Sigma}^{-1}$ would give $\frac{1}{a^2}$ and $\frac{1}{b^2}$. However, I still need to find the angle $\theta$.