How to Draw Ellipse of Covariance Matrix

2x2 covariance matrix can be represented by an ellipse. This method helps visualize multivariate normal distributions and correlation matrices. Parametric equations and formulas for radii + rotation are provided for covariance matrix shown below. This is followed by examples and explanations.

Radii and Rotation

θ is the angle in radians from positive x-axis to the ellipse's major axis in the counterclockwise direction. sqrt(λ1) is the radius of the major axis (the longer radius) and sqrt(λ2) is the radius of the minor axis (shorter radius). atan2()'s first parameter is y and second is x.

Parametric Equation

When drawing confidence ellipse of a bivariate normal distribution, the ellipse is translated such that its center is at the mean of the distribution: where μx and μy are the means. Note that covariance matrix by itself does not contain information about the mean.

Examples

Same values in diagonals

Ellipse is rotated 45 degrees if correlation (off-diagonal) is positive regardless of its magnitude. Similarly -45 degrees if correlation is negative.

Diagonal matrix

Zeros in off-diagonals means zero correlation. Ellipse axes are parallel to coordinate axes (no rotation).

Correlation matrix

Correlation matrix has 1 in diagonals and values betwen -1 and 1 inclusive in off-diagonals. Ellipse size remains the same (always touches square of side 2 units). Whether the correlation is positive or negative can be observed by the orientation of the ellipse. The amount of correlation can be interpreted by how thin the ellipse is.

How It Works

Below is a list of parametric equations starting from that of a general ellipse and modifying it step by step into a prediction ellipse, showing how different parts contribute at each step.

(1) Ellipse

(2) Rotated Ellipse

(3) Ellipse Representing Covariance Matrix

(4) Ellipse at Mahalanobis Distance = 2

This is like saying 2 standard deviations away from the mean.

(5) 95% Prediction Ellipse

A random point falls inside this ellipse with 95% probability. This is also known as error ellipse and confidence ellipse. Mahalanobis distance squared has chi-squared distribution. Cummulative chi-squred: Inverse chi-squared: