How to get a "Gaussian Ellipse"? Assume I have a multidimensional Gaussian distribution defined by a mean $\mu$ and covariance matrix $\Sigma$. I want to calculate an iso contour / ellipsoid that is aligned with the shape of the PDF.
i.e like this:

Or like the projected region in this image:

In more general terms, is there an easy way to define the isocontour of a Gaussian function for plotting?
 A: In $n$ dimensions, the $\text{pdf}$ is an exponential function of
$$(p-\mu)^T\Sigma^{-1}(p-\mu)$$ and the isocontours are the (hyper)ellipses of equation
$$(p-\mu)^T\Sigma^{-1}(p-\mu)=l.$$
By diagonalizing $\Sigma^{-1}$,
$$(p-\mu)^TP\Lambda P^{-1}(p-\mu)=l,$$ where $P$ should be taken orthogonal to correspond to a pure rotation.
In the transformed coordinates,
$$t^T\Lambda t=l,$$
leading to the classical 2D case,
$$\frac{\lambda_u}lu^2+\frac{\lambda_v}lv^2=1.$$
This can be drawn by the parametric equations
$$\begin{cases}u=\dfrac l{\sqrt{\lambda_u}}\cos\theta,\\v=\dfrac l{\sqrt{\lambda_v}}\sin\theta,\end{cases}$$
then reverting to the original coordinates.
For the 3D case, you have the option of using spherical coordinates
$$\begin{cases}u=\dfrac l{\sqrt{\lambda_u}}\cos\theta\sin\phi,\\v=\dfrac l{\sqrt{\lambda_v}}\sin\theta\sin\phi,\\w=\dfrac l{\sqrt{\lambda_w}}\cos\phi\end{cases},$$ giving a system of meridians and parallels.
You also have the option of freezing one coordinate at a time to obtain a triple network of elliptical cross-sections of equation
$$\frac{\lambda_u}lu^2+\frac{\lambda_v}lv^2=1-\frac{\lambda_w}lw^2,$$ i.e.
$$\begin{cases}x'=\dfrac{l\sqrt{1-\dfrac{\lambda_w}lw^2}}{\sqrt{\lambda_u}}\cos\theta,\\y'=\dfrac{l\sqrt{1-\dfrac{\lambda_w}lw^2}}{\sqrt{\lambda_v}}\sin\theta,\\z'=w\end{cases}$$
and similar for the other axis.
For the 3D representation, the points undergo both the diagonalizing  and the viewing transformations. The latter is usually made of a rotation, a translation and possibly a perspective projection, and the two rotations and translations can be combined.
Bonus:
For 4D, projecting a wireframe from 4D to 2D will be completely unreadable. You can think of using time as the fourth dimension, and consider constant-time cross-sections, such that the fourth coordinate of $p$ is held constant.
Here things get a little more complicated as the above condition translates to a hyperplane equation in the diagonalized coordinates, and you will have to construct the intersection(s) of a hyperellipsoid and this hyperplane obtained by sweeping over time. This will result in a set of 3D ellipsoids that you can render by the above method. Beware anyway, that the center is not fixed.
The movie will show an ellipsoid inflating from a single point, with its center moving along a line segment (not necessarily a main axis). After meeting the middle point, it will deflate symmetrically and vanish.
In the 4D diagonalized coordinates, the hyperellipsoid will look like
$$au^2+bv^2+cw^2+dt^2=1$$
and the constant-time constraint will be write
$$pu+qv+rw+st=1.$$
Hence by eliminating a coordinate, say $t$, we get the ellipsoid
$$au^2+bv^2+cw^2+d\left(\frac{1-pu-qv-rw}s\right)^2=1.$$
A: The axes are the eigenvectors of the covariance matrix; the semi-axes are (proportional to) the reciprocals of the eigenvalues of the covariance matrix.
