Mathematica noob here, and I'm having some issues plotting 90% confidence ellipses of a small-variance 2D Gaussian PDF. I have it working perfectly fine for larger covariance matrices, but absolutely no luck with these tiny ones! Here's my code:
Sigma={{0.0093041, -0.00126552}, {-0.00126552, 0.00020695}}; xv={X,Y}; x0={66.2782, 0.791879}; pdf = 1/Sqrt[(2 \[Pi])^Length[xv] Det[Sigma]]Exp[-(xv - x0).Inverse[Sigma].(xv - x0)/2] ContourPlot[pdf, {X, 66, 66.6}, {Y, .76, .83}, PlotRange -> All, PlotPoints -> 100] Which gives me a standard multivariate Gaussian, albiet with contours at probabilitiesdensities of 50-250.. Which I guess is fine assuming such a small range. Also, just as a quick check, the integral does indeed equal 1:
NIntegrate[pdf, {X, 60, 70}, {Y, .5, .9}](*=1*) Now, trying to compute the 90% confidence regions.. Following the solution here: https://mathematica.stackexchange.com/a/20481/58658, I do the following:
f[x_, y_, t_: 0] := With[{z = pdf /. X -> x /. Y -> y}, z Boole[z >= t]]; r = FindRoot[NIntegrate[f[x, y, t], {x, 60, 70}, {y, .7, .9}, AccuracyGoal -> 3, PrecisionGoal -> 6] - 0.90, {t, 0, 2}, Method -> "Brent", AccuracyGoal -> 3, PrecisionGoal -> 6]; Which results in numerous errors "The integrand has evaluated to non-numerical values for all sampling points in the region..", or non-sensical answers as I play around with the integration ranges. I don't really see how to make this work, seeing as all the pdf valuesdensities evaluate to be much greater than 1 in such a small range!! Does anyone have any experience with issues like this? Or any clever roundabout ways of doing this?
Thanks so much in advance!