Normal data in 2-D is modelled as a Gaussian with mean μ=(0,0) and covariance Σ=[10.90.91]. What is the squared Mahalanobis distance of x1=(1,1) and of x2=(1,−1), which is anomalous at the 1% level, and would a model that treats the two features as independent Gaussians notice the difference?

Unsupervised learning, Anomaly detection
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can invert a 2×2 covariance matrix, compute Mahalanobis distances, and see why modelling the correlation matters.

Key idea

The squared Mahalanobis distance d2=(x−μ)⊤Σ−1(x−μ) measures distance in units of the data's own spread, taking correlation into account. The Gaussian density is proportional to exp⁡(−12d2), so a large d2 means low density. For normal 2-D data, d2 follows a chi-squared distribution with 2 degrees of freedom (χ22), so flag x if d2 exceeds its 99% point, −2ln⁡0.01≈9.21.

Steps

  1. Invert the covariance. For a 2×2 matrix, [abba]−1=1a2−b2[a−b−ba], so Σ−1=10.19[1−0.9−0.91].
  2. For x1=(1,1): d2=1−0.9−0.9+10.19=0.20.19≈1.05.
  3. For x2=(1,−1): d2=1+0.9+0.9+10.19=3.80.19=20.
  4. Compare with 9.21: x1 is normal and x2 is anomalous. Its density is lower than that of x1 by a factor of e−(20−1.05)/2≈8×10−5.
  5. Independent-features model: each coordinate is treated as N(0,1) on its own, so both points get d2=12+12=2 and look equally normal. Only the full covariance sees that x2 breaks the strong positive correlation: when x1 goes up, x2 normally goes up too.
  6. Add the practical side: estimate μ and Σ from clean training data, and choose the threshold on a labelled validation set (for example, to maximise F1), not on the test set.

Common mistakes

How long your answer should be

Half a page of arithmetic; about 4 minutes.

Read this

Previous in Unsupervised learning: A data matrix X has one feature per column. Its covariance matrix decomposes as C=UΛU⊤ with U=12[11−11] and Λ=diag⁡(99,1). (a) What is the shape of X? (b) What steps compute C from X, and what is C explicitly? (c) To what dimension would you reduce the data with PCA, onto which direction, and why?
Next in Unsupervised learning: A 2-D dataset has two clusters: 50 points evenly spaced on a circle of radius 1 and 200 points evenly spaced on a circle of radius 5, both centred at the origin. (a) Can fuzzy c-means with c=2 separate the two rings? (b) Can DBSCAN, and which values of ε and MinPts work, which fail, and why?