Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm working on a project right now where I have Gaussian distributions, and I want to create a graphic that represents them. I'm not sure how to generate the ellipse that represents say 1 standard deviation away from the mean.

How do I convert the covariance matrix into the major & minor axes and angle away from horizontal?

share|cite|improve this question

I'm not sure what it means for a draw from a bivariate normal distribution to be "one standard deviation" away from the mean. The contours are given by $\{x: (x - \mu) ^T \Sigma^{-1} (x - \mu) = k\}$ which is the same as $L^{-T}\{z: \|z\|^2 = k\} + \mu$ where $LL^T = \Sigma^{-1}$ is the Cholesky decomposition of the precision matrix, so just get the Cholesky decomposition and apply that affine transformation to a circle with radius $\sqrt k$ centred at the origin to get a contour. The quantity $(X - \mu)^T \Sigma^{-1} (X - \mu)$ has a $\chi^2_p$ distribution ($p = 2$ since we are dealing with bivariate normal, so it is exponential in this case), so one could take $k$ corresponding to quantiles of a $\chi^2_p$ to get contours corresponding to the quantiles of the distance from the mean with respect to the Mahalanobis metric.

share|cite|improve this answer
Contours! That was the word I couldn't think of. I knew it started with a C. – MalcolmOcean Aug 22 '12 at 23:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.