An isolation forest uses sub-samples of size ψ=256 and scores a point with s(x,ψ)=2−E[h(x)]/c(ψ), where c(ψ)=2(ln⁡(ψ−1)+0.5772)−2(ψ−1)ψ. (a) Compute c(256). (b) Find s for average path lengths E[h]=4, 10.24 and 12 and say what each means. (c) Why is c(ψ) in the formula?

Unsupervised learning, Anomaly detection
Level L3 Intermediate. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can use the isolation-forest scoring formula and explain the normalisation by c(ψ).

Key idea

c(ψ) is the expected path length of an unsuccessful search in a binary search tree built from ψ points, which normalises E[h] so that scores are comparable and E[h]=c(ψ) gives s=0.5.

Steps

  1. ln⁡255=5.5413, so c(256)=2(5.5413+0.5772)−2⋅255/256=12.237−1.992≈10.245.
  2. For E[h]=4: E[h]/c=0.3904, so s=2−0.3904≈0.763. This is well above 0.5, which means that the point is isolated very quickly. It is a likely anomaly.
  3. For E[h]=10.24: this is almost exactly c(256), so s≈2−1=0.5. The point is as hard to isolate as an average point, with no evidence of an anomaly.
  4. For E[h]=12: E[h]/c=1.171, so s=2−1.171≈0.444<0.5. This is a deep, well-embedded point: normal.
  5. Why c(ψ): the average depth in a random binary tree grows like ln⁡ψ, so the raw path length depends on the sample size. Dividing by c(ψ) makes the score independent of ψ.
  6. Limits: E[h]→0 gives s→1 (anomaly) and E[h]→∞ gives s→0. The score is therefore in (0,1) and is compared with a threshold or the contamination rate.

Common mistakes

How long your answer should be

Half a page; 4–5 minutes.

Last checked on 4 December 2026.

Read this

Previous in Unsupervised learning: Five points lie on a unit half-circle at angles 0∘,45∘,90∘,135∘,180∘. Isomap uses a neighbourhood graph in which two points are joined if they are less than 0.8 apart. (a) What is the graph (geodesic) distance between the first and last points, and how does it compare with the straight-line distance and the true arc length? (b) What goes wrong if the radius is too large, for example 1.5?
Next in Unsupervised learning: In alternating least squares (ALS) for matrix factorisation, a user has rated two items, with item vectors q1=(1,0) and q2=(1,1) fixed and ratings 3 and 5. (a) Derive the update that minimises ∑i(ri−p⊤qi)2+λ∥p∥2 for the user vector p. (b) Compute p for λ=1, and for λ=0. (c) Why is ALS attractive for large recommenders?