2.5.13 · D1Unsupervised Learning

Foundations — Anomaly detection methods

2,627 words12 min readBack to topic

Before you can read the parent note Anomaly detection methods, you must be able to read its language. This page builds every symbol it uses, from absolute zero, in the order they depend on each other. If you already know one, skip it — but each one below is assumed by the parent, so we build it here.


1. A data point and the space it lives in

The picture: think of a flat sheet of graph paper. The horizontal axis is feature 1 (say CPU usage), the vertical axis is feature 2 (memory). One server is a single dot; the arrow from the corner to that dot is the vector .

Figure — Anomaly detection methods

Why the topic needs it: anomaly detection compares one point to a whole cloud of points. To do that we must first agree that every point is a location in the same room. Two features → a flat sheet (); three → a box (); more → we can't draw it, but the maths is identical.

Reveal to lock it in:

means...
the 3rd whole observation in your dataset.
means...
the 2nd feature (coordinate) of a single point.

2. Summing many points:

The picture: imagine a row of boxes. walks along them left to right, tipping each box's contents into one running total.

Why the topic needs it: to find the "center of the crowd" you literally add every point up and divide by how many there are.


3. The mean — the center of normal

The picture: if each data dot were a coin of equal weight on the graph paper, is the exact spot where the sheet would balance on a pin. It is itself a point in — one arrow to the middle of the crowd.

Why the topic needs it: "normal" needs a center. Every method measures anomalies as distance from this center (or from the crowd built around it).


4. Reading a matrix: transpose, determinant, inverse

The next section needs three matrix operations, so we build them before using them.

The picture: a column vector standing up; the transpose lays it down flat on its side.


5. Spread and shape: variance and the covariance matrix

Figure — Anomaly detection methods

The picture: is the ellipse drawn around the crowd — the diagonal sets the width along each axis, the off-diagonal sets the tilt. The figure above shows how the same with different gives a circle, a stretched blob, or a tilted cigar.


6. Distance measured the smart way: Mahalanobis distance

Figure — Anomaly detection methods

Why the topic needs it: this single number is the heart of Gaussian anomaly detection. Big Mahalanobis distance → far from normal → low probability → anomaly.


7. Turning distance into probability: , , and

Why this tool and not another? We want a rule where near the center → high value, far away → value crashing toward zero, but never negative. The exponential does exactly this smoothly. That is why the Gaussian formula wraps the Mahalanobis distance inside .


8. Symbols for the other two methods

You don't need to master these three yet — the parent derives them. You only need to recognize the symbols as "distance-like" (), "similarity-like" (), and "tuning dials" ().


Prerequisite map

Real numbers R

Vector x in R^n

Summation sum over i

Mean mu = center

Transpose Determinant Inverse

Variance sigma squared

Covariance matrix Sigma = shape

Mahalanobis distance

Exponential turns distance into p of x

Threshold epsilon flags anomaly

Anomaly Detection Methods

Path length h and score s

Kernel K and dial nu


Equipment checklist

Test yourself — say the answer out loud before revealing.

I can explain the difference between and
is the whole -th data point; is the -th feature inside one point.
I know what means
the space of lists of real numbers — one point per observation with features.
I can read
add the thing on the right once for each from 1 to .
I know what is and can picture it
the average location — the balance point of the data cloud.
I know what does
transpose — flips a matrix across its diagonal; turns a column vector into a row vector.
I can write the variance of feature
— average squared distance from the mean.
I know what each entry of is
diagonal = variance of feature ; off-diagonal = covariance of features and .
I can tell the summation from the covariance matrix
the summation has limits attached; the matrix stands alone (or as , ).
I know what and do
determinant = area/volume-scaling factor (the ellipse's area scales like ); inverse = "undo" that reshapes the cloud into a unit circle.
I can explain why is a problem
no inverse exists — the cloud has collapsed to a line, formula breaks.
I know why we use Mahalanobis instead of straight-line distance
it measures distance in units of the cloud's own spread per direction, not treating all directions equally.
I know why is used
it turns big distances into tiny positive values smoothly — far points get near-zero probability.
I can write the full Gaussian density
.
I know what means
the point's probability is below the tunable cutoff, so it is flagged as an anomaly.
I know what is in Isolation Forest
the expected average path length for points, , used to normalize the score.
Recall Quick self-check: which symbol answers "how far, adjusted for shape?"

The Mahalanobis distance .