# Finding the area of Gaussian 90% error ellipses

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}}

x0={67.1252,0.686112}

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:

chi90=4.605
r1=Sqrt[Chi90*Eigenvalues[S][[1]]]
r2=Sqrt[Chi90*Eigenvalues[S][[2]]]


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:

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!!

• 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. – zack May 1 at 16:13
• Understood. I'll try to read more carefully next time. And I'll delete my "duplicate" comment. – JimB May 1 at 17:10

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 *)

• 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. – zack May 1 at 17:16