Algorithm Search⌘K

Definitionadvanced

Halfspace depth

Also called Tukey depth, location depth.

The depth of a point is the least number of data points in a closed halfspace that contains it. It orders multivariate data from the centre outward.

The halfspace depth of a point xx in a data set is the least number of data points in a closed halfspace that contains xx. A point deep inside the cloud has many points on every side, and a point outside the convex hull has depth 0. In one dimension it is the familiar rank depth of the median: the depth of xx is the smaller of the number of points at or below xx and the number at or above xx. Tukey proposed it in 1974 to draw bivariate data, and the deepest point is the Tukey median.

Definition

Let X=(x1,…,xn)X = (x_1, \ldots, x_n) be a sample of points in Rd\mathbb{R}^d; points may repeat, and each copy counts. For a point x∈Rdx \in \mathbb{R}^d, the halfspace depth of xx in XX is

hd⁡(x;X)=min⁡H∋x#{i:xi∈H},\operatorname{hd}(x; X) = \min_{H \ni x} \#\{i : x_i \in H\},

where HH runs over the closed halfspaces that contain xx. A closed halfspace with xx on its boundary contains no more points than a larger parallel one, so it is enough to use the halfspaces with xx on the boundary:

hd⁡(x;X)=min⁡∥u∥=1#{i:u⊤xi≥u⊤x}.\operatorname{hd}(x; X) = \min_{\|u\| = 1} \#\{i : u^\top x_i \ge u^\top x\}.

Some authors divide by nn and use the fraction in [0,1][0, 1]. For a probability distribution PP on Rd\mathbb{R}^d, the population depth is hd⁡(x;P)=inf⁡{P(H):H a closed halfspace with x∈H}\operatorname{hd}(x; P) = \inf\{P(H) : H \text{ a closed halfspace with } x \in H\}, and the sample depth divided by nn is the depth for the empirical distribution.

The depth region of level kk is Dk={x:hd⁡(x;X)≥k}D_k = \{x : \operatorname{hd}(x; X) \ge k\}. The maximal depth is k∗=max⁡xhd⁡(x;X)k^* = \max_x \operatorname{hd}(x; X), and a point with depth k∗k^* is a deepest point.

These facts follow from the definition.

  • Affine invariance. For an invertible matrix AA and a vector bb, hd⁡(Ax+b;AX+b)=hd⁡(x;X)\operatorname{hd}(Ax + b; AX + b) = \operatorname{hd}(x; X), because x↦Ax+bx \mapsto Ax + b maps closed halfspaces onto closed halfspaces.
  • Depth and the hull. hd⁡(x;X)≥1\operatorname{hd}(x; X) \ge 1 if and only if xx is in the convex hull of XX. If xx is outside the hull, a hyperplane strictly separates xx from the hull, and the closed side of xx holds no point. If xx is in the hull and a closed halfspace H∋xH \ni x held no data point, then all points would lie in the open complement of HH, and so would their convex combination xx.
  • Regions are convex. DkD_k is the intersection of all closed halfspaces that hold at least n−k+1n - k + 1 points. If x∉Hx \notin H for such an H={y:u⊤y≤c}H = \{y : u^\top y \le c\}, then u⊤x>cu^\top x > c, and the closed halfspace {y:u⊤y≥u⊤x}\{y : u^\top y \ge u^\top x\} holds xx and at most k−1k - 1 points, so hd⁡(x)<k\operatorname{hd}(x) < k. If hd⁡(x)≤k−1\operatorname{hd}(x) \le k - 1 by a direction uu, then at least n−k+1n - k + 1 points have u⊤xi<u⊤xu^\top x_i < u^\top x, and a slightly lower level c<u⊤xc < u^\top x gives such an HH that misses xx. So each DkD_k with k≥1k \ge 1 is a compact convex set, and D1⊇D2⊇⋯D_1 \supseteq D_2 \supseteq \cdots.
  • Monotone along rays. If θ\theta is a deepest point, the depth does not increase along each ray that starts at θ\theta, because each region is convex and holds θ\theta. The depth falls to 0 outside the hull. Zuo and Serfling (2000) take affine invariance, a maximum at a centre, this monotonicity and the vanishing at infinity as the axioms of a statistical depth function. Halfspace depth is their model case.
  • The range of the maximal depth. ⌈n/(d+1)⌉≤k∗≤n\lceil n/(d+1) \rceil \le k^* \le n. The lower bound is the centerpoint theorem, a consequence of Helly's theorem; the proof is on the Tukey median page. If the points are distinct, then k∗≤⌈n/2⌉k^* \le \lceil n/2 \rceil. Take a hyperplane through xx that misses all data points other than xx. If xx is not a data point, the smaller closed side holds at most ⌊n/2⌋\lfloor n/2 \rfloor points. If xx is a data point, it holds at most ⌊(n−1)/2⌋\lfloor (n-1)/2 \rfloor other points plus xx, which is ⌈n/2⌉\lceil n/2 \rceil.

The depth of one point in the plane takes O(nlog⁡n)O(n \log n) time (Rousseeuw and Ruts 1996). Sort the vectors xi−xx_i - x by angle and slide a half-turn around the circle; the Tukey median page gives the algorithm and its proof. This is optimal: Aloupis and others (2002) prove an Ω(nlog⁡n)\Omega(n \log n) lower bound. In fixed dimension dd, exact algorithms take O(nd−1log⁡n)O(n^{d-1} \log n) time (Dyckerhoff and Mozharovskyi 2016). When dd is part of the input, the problem is the densest hemisphere problem, which is NP-complete (Johnson and Preparata 1978). So in high dimension one uses the minimum over a finite set of random directions, which is an upper bound on the depth.

Examples and non-examples

One dimension. For the sample (1,2,4,7,9)(1, 2, 4, 7, 9) a closed halfspace is a closed half-line, so hd⁡(x)=min⁡(#{xi≤x},#{xi≥x})\operatorname{hd}(x) = \min(\#\{x_i \le x\}, \#\{x_i \ge x\}). The depths of the five points are 1,2,3,2,11, 2, 3, 2, 1, and the point 5 has depth min⁡(3,2)=2\min(3, 2) = 2. The deepest point is the median 4, with depth 3. For an even sample the deepest set is the whole median interval.

Seven points in the plane. Take

X={(0,0),(6,0),(0,6),(6,6),(2,3),(3,1),(9,9)}.X = \{(0, 0), (6, 0), (0, 6), (6, 6), (2, 3), (3, 1), (9, 9)\}.

The depths of the seven data points are 1,1,1,2,2,2,11, 1, 1, 2, 2, 2, 1. For x=(3,3)x = (3, 3), the vectors xi−xx_i - x in angle order are (3,3)(3,3), (6,6)(6,6), (−3,3)(-3,3), (−1,0)(-1,0), (−3,−3)(-3,-3), (0,−2)(0,-2), (3,−3)(3,-3). Every half-open half-turn of directions holds at least 3 of them, and the half-turn that starts at (−3,−3)(-3,-3) holds exactly (−3,−3)(-3,-3), (0,−2)(0,-2) and (3,−3)(3,-3). So hd⁡((3,3))=3\operatorname{hd}((3,3)) = 3. A closed halfplane that shows it: the points on or below the line through (3,3)(3,3) with slope 9/119/11. It holds (0,0)(0,0), (3,1)(3,1) and (6,0)(6,0) only. The maximal depth is k∗=3=⌈7/3⌉k^* = 3 = \lceil 7/3 \rceil, and D3D_3 is the segment from (18/7,18/7)(18/7, 18/7) to (3,3)(3,3). The point (9,9)(9, 9) is far out, but it moves no part of D3D_3 off the diagonal. The Tukey median page builds D3D_3 step by step.

Points outside the hull. For the same XX, the point (9,0)(9, 0) has depth 0: the closed halfplane y≤x−7y \le x - 7 holds it and holds no data point.

Non-example: the coordinatewise median. The coordinatewise median is not a deepest point in general, and it can have depth 0. For the three points (1,0,0)(1,0,0), (0,1,0)(0,1,0) and (0,0,1)(0,0,1) in R3\mathbb{R}^3, the coordinatewise median is (0,0,0)(0,0,0). It is not in the convex hull (the plane x+y+z=1x + y + z = 1 holds all three points), so its depth is 0. The deepest points are the triangle itself, at depth 1. The coordinatewise median is also not affine equivariant.

Non-example: the count in a ball. The number of data points within distance rr of xx is a density estimate, not a depth. It is large inside a dense cluster at the edge of the cloud, and it changes under a linear change of scale. Halfspace depth is large only near the centre of the whole cloud.

  • Tukey median. The centre of gravity of the deepest region Dk∗D_{k^*}. Its breakdown point is at least 1/(d+1)1/(d+1) for data in general position (Donoho and Gasko 1992).
  • Centerpoint. A point of depth at least ⌈n/(d+1)⌉\lceil n/(d+1) \rceil. It always exists; the Helly theorem page proves it.
  • Convex hull peeling depth. The index of the convex layer that holds a point. It also orders points from the outside in, but it is not the same order as halfspace depth.
  • Simplicial depth. Liu (1990): the number of simplices with vertices in the data that contain xx. It is another affine invariant depth, with a different deepest point.
  • Geometric median. The minimizer of the sum of Euclidean distances. It has breakdown point 1/2, but it is only orthogonally equivariant, not affine equivariant.
  • Empirical distribution function. In one dimension, hd⁡(x)/n=min⁡(Fn(x),1−Fn(x−))\operatorname{hd}(x)/n = \min(F_n(x), 1 - F_n(x^-)).

References

  1. John W. Tukey, Mathematics and the picturing of data, in R. D. James (ed.), Proceedings of the International Congress of Mathematicians, Vancouver 1974, Volume 2, Canadian Mathematical Congress, Montreal, 1975, pp. 523 to 531, The whole paper (depth of a point as the least number of data points in a halfplane that contains it, used to draw bivariate data)
  2. David L. Donoho and Miriam Gasko, Breakdown properties of location estimates based on halfspace depth and projected outlyingness, The Annals of Statistics 20(4), 1992, pp. 1803 to 1827 (depth regions, the bound ceil(n/(d+1)) on the maximal depth, and the breakdown of the deepest point)
  3. Peter J. Rousseeuw and Ida Ruts, Algorithm AS 307: Bivariate location depth, Journal of the Royal Statistical Society, Series C (Applied Statistics) 45(4), 1996, pp. 516 to 526, The whole paper (the depth of one point in the plane in O(n log n) time by an angular sort)
  4. Yijun Zuo and Robert Serfling, General notions of statistical depth function, The Annals of Statistics 28(2), 2000, pp. 461 to 482 (the four properties of a depth function, and the halfspace depth as the model case)
  5. Greg Aloupis, Carmen Cortés, Francisco Gómez, Michael Soss and Godfried Toussaint, Lower bounds for computing statistical depth, Computational Statistics and Data Analysis 40(2), 2002, pp. 223 to 229, The whole paper (an Omega(n log n) lower bound for the halfspace depth of one point in the plane)
  6. David S. Johnson and Franco P. Preparata, The densest hemisphere problem, Theoretical Computer Science 6(1), 1978, pp. 93 to 107, The whole paper (the densest hemisphere problem is NP-complete when the dimension is part of the input)
  7. Rainer Dyckerhoff and Pavlo Mozharovskyi, Exact computation of the halfspace depth, Computational Statistics and Data Analysis 98, 2016, pp. 19 to 30, The whole paper (exact algorithms in O(n^d) and O(n^(d-1) log n) time in dimension d)

Where this leads

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/NY6SD7/text.yaml