# How to fit min. area ellipse around data point

1. Nov 6, 2009

### Amrita

Hi,

I am having some 2d and 3d data files (from some nmr experiment, as a matter of fact) and the data plot for that is such that most of the points are coming together now I want to draw ellipse around 2d data point and ellipsoid around 3d data point with the condition that 90% (or any confidence interval) of data will fall inside it. Moreover, these ellipse / ellipsoid should have the minimum area/volume. How to do that can anyone advice me?
I have been trying it in Matlab. But if any other software does this efficiently, kindly inform in details.

2. Nov 8, 2009

### DrGreg

If x1, x2, x3 ... are the column vectors for your points, form the 2×2 or 3×3 covariance matrix

$$\textbf{R} = \frac{1}{N}\sum_{n=1}^N \textbf{x}_n \textbf{x}_n^T$$​

The ellipse / ellipsoid you want will have an equation of the form

$$\textbf{x}^T\textbf{Rx} = r^2$$​

for some suitable value of r. For arbitrary data you can just calculate the value of rn for each data point x = xn and take the 90th percentile (or whatever).

You should be able to all this in MATLAB.

3. Nov 9, 2009

### DrGreg

Correction

My response above is based on the assumption that your data has zero mean. If the mean of your data is not negligible (i.e. if you want an ellipse that isn't centred on the origin) you'll need to subtract the mean first before you do anything else.