I'm trying to find the area of 90% Gaussian error ellipses, which should be easy because there is a direct method to find the length of the semi-major and semi-minor axes, found from multiple resources (such as here): $l_j=\sqrt{\lambda_j\chi^2_{\alpha,d}}$

where $l_j$ is the length of axis $j$, $\lambda_j$ is the $j$-th eigenvalue of the covariance matrix $\Sigma_{ij}$, $d$ is the number of dimensions, $\alpha$ is the confidence interval $(1-\alpha)$, and $\chi^2_{\alpha,d}$ is the corresponding chi-squared value, found to be $4.605$ for the two-dimensional 90% confidence interval. So here's what I'm doing:

S={{126.509, 2.29787}, {2.29787, 0.197431}}


pdf=Exp[-({X,Y} - x0).Inverse[S].({X,Y} - x0)/2]/Sqrt[(2 \[Pi])^2 Det[S]]

c90=(2 \[Pi])^(-1) Det[S]^(-1/2) Exp[-InverseCDF[ChiSquareDistribution[2], 0.9]/2]

$S$ is my covariance matrix, and $x0$ is the means of my data. To test my calculations, I'm going to compare my computed error ellipse to the actual one, found with a contour plot of "$pdf$" at a height of $c90$, which is the value of the 90th confidence interval (This has been verified, and indeed the integral up to that value does add up to $0.9$).

Next, I compute the values of the axes of the 90% error ellipse:


And then I can compare the actual 90% contour, and my computed one with the semi-major/minor axes (neglecting tilt for now):

Show[ContourPlot[pdf, {X, -5, 140}, {Y, -1, 2.5}, PlotRange -> All,Evaluate[plotOptions["X", "Y", 700]], Contours -> {c90}, ContourStyle -> {Darker[Purple]}, ContourShading -> None],Plot[y /.Solve[((x - x0[[1]])/r1)^2 + ((y - x0[[2]])/r2)^2 == chi90], {x,
0, 140}]]

Which gives me the following result:

enter image description here

They don't agree at all! Not even the relative size of the axes match up. Why would I be getting such different results? Any help is much appreciated!!

  • $\begingroup$ Yes, that answer shows how one could find the 90% contour, but here I'm trying to calculate the semi-minor and semi-major axes so I can compute the area of the contour. $\endgroup$
    – zack
    May 1, 2019 at 16:13
  • 1
    $\begingroup$ Understood. I'll try to read more carefully next time. And I'll delete my "duplicate" comment. $\endgroup$
    – JimB
    May 1, 2019 at 17:10

1 Answer 1


Here is an alternative to finding the area without determining the semi-minor and semi-major axes:

(* Data summary *)
S = {{126.509, 2.29787}, {2.29787, 0.197431}};
x0 = {67.1252, 0.686112};

(* Determine implicitly defined ellipse: a*x^2 + b*x*y + c*y^2 = 1 *)    
p = Expand[{x, y}.Inverse[S].{x, y}/InverseCDF[ChiSquareDistribution[2], 0.9]]
(* 0.0021766 x^2 - 0.0506662 x y + 1.39471 y^2 *)
a = Coefficient[p, x^2];
b = Coefficient[p, x y];
c = Coefficient[p, y^2];

(* Area *)
area = 2 π/Sqrt[4 a c - b^2]
(* 64.2083 *)
  • $\begingroup$ This method works very nicely @JimB! Thank you so much for the help :) I was so stuck on trying to find the axes, but this is a very nice workaround. $\endgroup$
    – zack
    May 1, 2019 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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