What is the VC dimension of the class of closed intervals ha,b(x)=1[a≤x≤b] on the real line, and why?

Learning theory, VC dimension
Level L2 Elementary. Length Medium. Nature Th+Mat Both.

What's being asked

Whether you can prove a VC dimension exactly, both by shattering a set and by finding a labelling that cannot occur.

Key idea

Two points can be shattered but three cannot, because the labelling (1,0,1) is impossible for an interval. So VCdim⁡=2.

Steps

  1. Lower bound: take x1<x2. Labelling (1,1): an interval covering both. (1,0): an interval around x1 that stops before x2. (0,1): the mirror image. (0,0): an interval far from both points. All four labellings occur, so VCdim⁡≥2.
  2. Upper bound: take any three points x1<x2<x3 and the labelling (1,0,1).
  3. An interval is a single connected piece. If it contains x1 and x3 it contains everything in between, including x2. So x2 would be labelled 1, a contradiction.
  4. So no set of three points is shattered (and the same argument works for any larger set). Hence VCdim⁡=2.

Common mistakes

How long your answer should be

Half a page; about 3 minutes.

Last checked on 4 December 2026.

Read this

Previous in Learning theory: Using Hoeffding's inequality, how large must a test set be so that the measured error of a fixed classifier is within 0.02 of its true error with probability at least 95%?
Next in Learning theory: The halving algorithm is run on a finite class of 1000 hypotheses and the labels are realisable (some hypothesis in the class is always correct). What is the largest number of mistakes it can make, and why?