Sandhya Indurkar

Math foundations

Norms and Distance: How Far Apart Are Two Feature Vectors?

L2 distance between two points in feature space

The idea

Once each row is a vector, comparison becomes geometry. Anomaly detection, duplicate search, and clustering all ask: how far is this point from a baseline? L2 (Euclidean) distance is the straight-line gap. L1 sums absolute coordinate differences and is less sensitive to one wild dimension.

Norms answer: What is the length of one vector? Distance answers: How far apart are two vectors in feature space?

Example: L1 and L2 distance from a baseline vector

Distance measures how far one feature vector sits from another. L2 is Euclidean; L1 sums absolute gaps.

L2 distance from a typical customer vector flags unusual spend and session patterns.

L2 distance

770.90

L1 distance

819.00

Verdict

Above threshold

L2 distance 770.90 exceeds threshold 400.00. L1 distance is 819.00. Scale features before comparing across tables with mixed units.

The math

L2 norm

||v||₂ = √(Σ vi²)

Length of a vector. Same formula as the hypotenuse in n dimensions.

L2 distance

d₂(a, b) = ||a − b||₂

Euclidean distance between two points. Default for embeddings when vectors are normalized.

L1 distance

d₁(a, b) = Σ |ai − bi|

Manhattan distance. One outlier coordinate adds linearly, not quadratically.

A simple application

Before you flag anomalies or near-duplicates, scale features so dollars and counts sit on comparable ranges. Pair L2 distance with cosine when vector length varies (see the dot product post). State your threshold and which norm you used.