Intuition The One Core Idea
Anomaly detection means learning a picture of what "normal" data looks like, then flagging any new point that lands far away from that picture. Every method on the parent page — Gaussian, Isolation Forest, One-Class SVM — is just a different way of drawing the boundary between "normal" and "too far".
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.
x and the vector arrow
A data point is one observation — one server reading, one credit-card transaction. We write it x . When that observation has several numbers (CPU and memory), we stack them into a vector : an arrow from the origin to a location on a grid.
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 ( 0 , 0 ) to that dot is the vector x = [ x 1 , x 2 ] .
R n — the room the data lives in
R means "all the real numbers" — the full number line, every decimal. R n means "a list of n real numbers", i.e. a point in n -dimensional space. The little n is just how many features each observation has.
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 R n room. Two features → a flat sheet (R 2 ); three → a box (R 3 ); more → we can't draw it, but the maths is identical.
Definition Superscripts vs subscripts — the trap
x ( i ) (with parentheses) means the i -th data point — the i -th server. x j (subscript, no parentheses) means the j -th feature of a point — the CPU number inside one server. These are totally different jobs done by look-alike notation.
Reveal to lock it in:
x ( 3 ) means...the 3rd whole observation in your dataset.
x 2 means...the 2nd feature (coordinate) of a single point.
Definition The summation sign
∑
∑ i = 1 m is a machine that says "add up the thing on my right, once for each i , starting at i = 1 and stopping at i = m ." Here m = how many data points you have.
The picture: imagine a row of m boxes. ∑ walks along them left to right, tipping each box's contents into one running total.
∑ i = 1 m x ( i ) = x ( 1 ) + x ( 2 ) + ⋯ + x ( m )
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.
μ
μ (Greek "mu") is the average location of all your normal points — the balance point of the cloud. Add every point, divide by the count m :
μ = m 1 ∑ i = 1 m x ( i )
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 R n — 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).
The next section needs three matrix operations, so we build them before using them.
( ⋅ ) T
The transpose flips a table across its diagonal — rows become columns. For a vector it turns a tall column of numbers into a wide row . We will need it to turn a product of two vectors into a full grid, and to turn a distance calculation into a single number.
The picture: a column vector standing up; the transpose lays it down flat on its side.
∣Σ∣
∣Σ∣ is one number that measures how much a matrix stretches area/volume — the area-scaling factor of the ellipse the matrix draws. A big value = a big, spread-out cloud; a value of zero = the cloud is squashed flat (degenerate — a warning sign). For a 2 × 2 matrix [ a c b d ] it is simply a d − b c .
Common mistake Determinant is a scaling factor, not the area itself
∣Σ∣ measures the squared stretch. The geometric area (2-D) or volume (n -D) of the covariance ellipse is proportional to ∣Σ ∣ 1/2 , not ∣Σ∣ . So a Σ with ∣Σ∣ = 800 draws an ellipse whose area scales like 800 .
Σ − 1
The inverse is the "undo" matrix: it rescales space so the tilted, stretched normal cloud becomes a plain unit circle. That is exactly what we need to measure "how many spreads away" a point is, regardless of tilt.
Common mistake Determinant zero → no inverse
If ∣Σ∣ = 0 you cannot compute Σ − 1 (you'd divide by zero). This happens when two features are perfectly copies of each other, collapsing the cloud to a line. The parent's Gaussian method silently assumes ∣Σ∣ > 0 .
Intuition Why a single center isn't enough
Two clouds can share the same center μ but look completely different: one a tight circle, one a stretched, tilted cigar. To describe "normal" we need not just where the crowd is, but how it spreads and which way it tilts . That is the job of Σ .
σ 2 — spread along one axis
Variance measures how far points typically sit from the mean along one feature. It is the average of squared distances from the mean (squaring makes negatives positive and punishes far points more). For feature j :
σ j 2 = Var ( x j ) = m 1 ∑ i = 1 m ( x j ( i ) − μ j ) 2
Big σ j 2 = wide spread; small = tight. The symbol σ (lower-case "sigma") is the standard deviation and σ 2 is its square, the variance.
Definition Covariance — do two features move together?
Covariance asks: when feature j is above its average, does feature k also tend to be above its average? For features j and k :
Cov ( x j , x k ) = m 1 ∑ i = 1 m ( x j ( i ) − μ j ) ( x k ( i ) − μ k )
Positive = they rise together (cloud tilts up-right); negative = one up while the other down; zero = no tilt. Note Cov ( x j , x j ) = σ j 2 — covariance of a feature with itself is its variance.
Definition The covariance matrix
Σ
Σ (capital "Sigma" — not the summation sign, same letter different job) packs all these numbers into a grid. For n features it is an n × n table:
Σ = m 1 ∑ i = 1 m ( x ( i ) − μ ) ( x ( i ) − μ ) T
Why this formula builds the grid: ( x ( i ) − μ ) is a column vector; multiplying it by its own transpose ( x ( i ) − μ ) T (a row) gives an n × n table whose ( j , k ) entry is ( x j ( i ) − μ j ) ( x k ( i ) − μ k ) . Averaging over all i makes the ( j , k ) entry exactly Cov ( x j , x k ) . So:
diagonal entry Σ j j = σ j 2 = variance of feature j ;
off-diagonal entry Σ j k = Cov ( x j , x k ) = covariance between features j and k .
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.
m or by m − 1 ?
This page uses m 1 (the population covariance) to match the parent note. Many statistics texts use m − 1 1 (the unbiased sample covariance) because it corrects a slight underestimate when m is small. For anomaly detection with large m the difference is negligible and does not change which points are anomalies — just know both conventions exist.
Common mistake Two different
Σ 's
The summation symbol ∑ i = 1 m and the covariance matrix Σ look identical. Tell them apart by context: ∑ has limits (i = 1 to m ) attached; the matrix Σ stands alone or appears with ∣Σ∣ , Σ − 1 .
Intuition Why plain straight-line distance fails
Straight-line ("Euclidean") distance treats every direction equally. But normal data spreads more in some directions than others. A point 3 units out along the wide axis is unremarkable; the same 3 units along the narrow axis is bizarre. We need distance measured in units of the cloud's own spread .
Definition Mahalanobis distance
The quantity ( x − μ ) T Σ − 1 ( x − μ ) is the squared Mahalanobis distance : how far x is from the center, rescaled by Σ − 1 so that one unit = one spread of normal data in that direction . The red point in the figure is the same Euclidean distance from center as the black one, but far more anomalous — because it lies along the narrow direction.
Why the topic needs it: this single number is the heart of Gaussian anomaly detection. Big Mahalanobis distance → far from normal → low probability → anomaly.
Definition The exponential
exp ( ⋅ ) and Euler's number
exp ( z ) means e z , where e ≈ 2.718 . The crucial fact: exp of a big negative number is tiny . exp ( − 56 ) is about 1 0 − 25 — practically zero. So as distance grows, exp ( − distance ) collapses fast.
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 exp ( − 2 1 ⋅ dist ) .
π and the normalization constant
π ≈ 3.14159 appears in ( 2 π ) n /2 ∣Σ ∣ 1/2 1 . Its only job is to scale the bell so the total probability sums to 1 (every possible point, added up, gives certainty). It doesn't change which points are anomalies — it just makes p ( x ) a genuine probability.
Definition Probability density
p ( x )
p ( x ) is the height of the bell-shaped "normal" surface at point x . High p ( x ) = right in the crowd; low p ( x ) = out in the wilderness. Assembling every piece we built — the normalization constant, the Mahalanobis distance, the exponential — gives the full multivariate Gaussian density:
ϵ
ϵ (Greek "epsilon", meaning "a tiny amount") is the cutoff. Any point with p ( x ) below ϵ gets flagged. Lower ϵ = stricter = fewer false alarms but risk missing real anomalies. It is a dial you tune , not something derived. The parent's whole rule is: anomaly if p ( x ) < ϵ .
h ( x ) and the normalizer c ( n ) (Isolation Forest)
h ( x ) = how many yes/no random cuts it takes to isolate point x from all others in a random tree. Few cuts → the point stands alone → anomaly. To compare scores across datasets of different sizes we divide by c ( n ) , the average path length expected for n points, which comes from the average depth of a search in a random binary tree:
c ( n ) = 2 H ( n − 1 ) − n 2 ( n − 1 ) , H ( k ) = ∑ i = 1 k i 1 ≈ ln ( k ) + 0.577
so for large n , c ( n ) ≈ 2 ln ( n ) . The anomaly score is then
s ( x ) = 2 ( − c ( n ) h ˉ ( x ) )
where h ˉ ( x ) is h ( x ) averaged over all trees. This lands between 0 and 1: near 1 = anomaly, near 0 = normal.
K ( x , x ′ ) and ν (One-Class SVM)
K ( x , x ′ ) is a similarity score between two points — 1 if identical, shrinking toward 0 as they differ. ϕ is an imaginary map into a higher-dimensional space where the kernel lets us measure similarity without ever visiting that space. ν (Greek "nu") is a dial in ( 0 , 1 ] that roughly sets the fraction of training points allowed to be outliers.
You don't need to master these three yet — the parent derives them. You only need to recognize the symbols as "distance-like" (h ), "similarity-like" (K ), and "tuning dials" (ν , ϵ ) .
Transpose Determinant Inverse
Covariance matrix Sigma = shape
Exponential turns distance into p of x
Threshold epsilon flags anomaly
Anomaly Detection Methods
Path length h and score s
Test yourself — say the answer out loud before revealing.
I can explain the difference between x ( i ) and x j x ( i ) is the whole i -th data point; x j is the j -th feature inside one point.
I know what R n means the space of lists of n real numbers — one point per observation with n features.
I can read ∑ i = 1 m add the thing on the right once for each i from 1 to m .
I know what μ is and can picture it the average location — the balance point of the data cloud.
I know what ( ⋅ ) T does transpose — flips a matrix across its diagonal; turns a column vector into a row vector.
I can write the variance of feature j σ j 2 = m 1 ∑ i ( x j ( i ) − μ j ) 2 — average squared distance from the mean.
I know what each entry of Σ is diagonal Σ j j = variance of feature j ; off-diagonal Σ j k = covariance of features j and k .
I can tell the summation ∑ from the covariance matrix Σ the summation has limits attached; the matrix stands alone (or as Σ − 1 , ∣Σ∣ ).
I know what ∣Σ∣ and Σ − 1 do determinant = area/volume-scaling factor (the ellipse's area scales like ∣Σ ∣ 1/2 ); inverse = "undo" that reshapes the cloud into a unit circle.
I can explain why ∣Σ∣ = 0 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 exp ( − distance ) is used it turns big distances into tiny positive values smoothly — far points get near-zero probability.
I can write the full Gaussian density p ( x ) p ( x ) = ( 2 π ) − n /2 ∣Σ ∣ − 1/2 exp ( − 2 1 ( x − μ ) T Σ − 1 ( x − μ )) .
I know what p ( x ) < ϵ means the point's probability is below the tunable cutoff, so it is flagged as an anomaly.
I know what c ( n ) is in Isolation Forest the expected average path length for n points, ≈ 2 ln ( n ) , used to normalize the score.
Recall Quick self-check: which symbol answers "how far, adjusted for shape?"
The Mahalanobis distance ( x − μ ) T Σ − 1 ( x − μ ) .