Tutorials › Statistical Learning (Graduate) › Regularity of Level Set Boundaries

Level Sets and Cluster Trees · Tutorial 668 of 989

Regularity of Level Set Boundaries

Learn when a density level set has a smooth boundary and how its gradient controls density changes near that boundary.

Advanced 11 min read

What You'll Learn

  • Define a density superlevel set and its boundary at a fixed threshold.
  • State the smoothness, compactness, and gradient conditions for regular boundary geometry.
  • Prove that a regular level set is locally a smooth hypersurface.
  • Derive a uniform linear comparison between density error and distance to the boundary.
  • Identify how critical thresholds can produce degenerate boundaries.

Why Boundary Regularity Matters

A density level set at threshold \(\lambda\) is the region where the density is at least \(\lambda\). Its boundary separates locations classified above the threshold from those below it. The shape of that boundary depends on more than the continuity of the density: at a critical threshold, the boundary can pinch, collapse, or fail to look locally like a smooth surface.

The central regularity condition is that the density changes in a nonzero direction at every point on the threshold boundary. Together with differentiability and compactness, this condition gives a precise local picture: the boundary is a smooth hypersurface, and moving a small distance normally to it changes the density to first order by the gradient magnitude times that distance.

Definitions and Regularity Conditions

Definition: Let \(f\) be a density on \(\mathbb{R}^d\) and let \(\lambda>0\). The superlevel set at threshold \(\lambda\) is \(L_\lambda=\{x\in\mathbb{R}^d:f(x)\geq\lambda\}\). Its boundary is denoted by \(\partial L_\lambda\). The level set is \(S_\lambda=\{x\in\mathbb{R}^d:f(x)=\lambda\}\).

For the results below, assume \(f\) is twice continuously differentiable on an open neighborhood of \(S_\lambda\), and that \(S_\lambda\) is compact. The key condition is \(\nabla f(x)\neq 0\) for every \(x\in S_\lambda\). Since the gradient is continuous and \(S_\lambda\) is compact, this condition implies a uniform lower bound: there is a constant \(c>0\) such that \(\|\nabla f(x)\|\geq c\) throughout \(S_\lambda\). Compactness also gives a finite upper bound \(C\) on \(\|\nabla f(x)\|\) there.

The nonvanishing-gradient condition says that the threshold is a regular value of \(f\). In dimension \(d\), a regular level set is locally a \((d-1)\)-dimensional surface. The density gradient is perpendicular to that surface, so the unit normal pointing toward increasing density is \(n(x)=\nabla f(x)/\|\nabla f(x)\|\).

Worked Examples at Regular and Critical Thresholds

Worked Example: A Standard Normal Density at a Regular Threshold

Let \(X\sim N(0,1)\), so \(f(x)=(2\pi)^{-1/2}\exp(-x^2/2)\). Choose \(\lambda=f(1)=(2\pi)^{-1/2}e^{-1/2}\). Solving \(f(x)=\lambda\) gives \(\exp(-x^2/2)=\exp(-1/2)\), hence \(x^2=1\) and \(S_\lambda=\{-1,1\}\).

Since \(f'(x)=-xf(x)\), the derivative at the two level-set points is \(f'(-1)=\lambda\) and \(f'(1)=-\lambda\). Both are nonzero. The superlevel set is the interval \([-1,1]\), whose boundary consists exactly of these two points. At either boundary point, moving a small distance \(t\) in the direction of increasing density raises the density by approximately \(\lambda t\); moving in the opposite direction lowers it by approximately the same amount.

Worked Example: An Elliptical Boundary in Two Dimensions

Consider the bivariate normal density \(f(x_1,x_2)=(4\pi)^{-1}\exp[-(x_1^2/2+x_2^2/8)]\). Set \(\lambda=e^{-1}/(4\pi)\). The equation \(f(x_1,x_2)=\lambda\) is equivalent to \(x_1^2/2+x_2^2/8=1\), an ellipse. Its gradient is \(\nabla f=-f(x_1,x_2)(x_1,x_2/4)\).

On the ellipse, \(f=\lambda\). To check that the gradient does not vanish, calculate \(\|\nabla f\|=\lambda\sqrt{x_1^2+x_2^2/16}\). The ellipse equation gives \(x_1^2=2-x_2^2/4\), so \(x_1^2+x_2^2/16=2-3x_2^2/16\). Because \(0\leq x_2^2\leq 8\), this quantity is at least \(2-24/16=1/2\). Thus \(\|\nabla f\|\geq\lambda/\sqrt{2}>0\) everywhere on the ellipse. The level boundary is regular, even though it is not circular.

Worked Example: A Critical Threshold Where Regularity Fails

For the same bivariate normal density, take the maximum threshold \(\lambda=f(0,0)=1/(4\pi)\). The superlevel set is now just \(\{(0,0)\}\), because the exponential factor is at most one and equals one only at the origin. Its level set is that same singleton.

At the origin, \(\nabla f(0,0)=(0,0)\), so the nonvanishing-gradient condition fails. The boundary is not a one-dimensional curve locally separating points with density above the threshold from points below it; there are no points with density strictly above this maximum. This example shows why differentiability alone does not guarantee regular boundary geometry.

Regular Level Sets Are Smooth Boundaries

Theorem: Suppose \(f\) is continuously differentiable on an open neighborhood of \(S_\lambda\), and \(\nabla f(p)\neq0\) at a point \(p\in S_\lambda\). In a sufficiently small neighborhood of \(p\), the level set \(S_\lambda\) is a continuously differentiable hypersurface. In that neighborhood, it is the boundary of \(L_\lambda\).

Proof. Since at least one partial derivative of \(f\) at \(p\) is nonzero, relabel the coordinates so that \(\partial f/\partial x_d(p)\neq0\). The implicit function theorem then gives a neighborhood in which the equation \(f(x)=\lambda\) is the graph \(x_d=g(x_1,\ldots,x_{d-1})\) of a continuously differentiable function. Thus the level set is locally a hypersurface.

To establish the boundary claim, use \(x_d\) as the coordinate in which the partial derivative is nonzero. By continuity, in a smaller neighborhood that derivative keeps a fixed sign. For fixed \(x_1,\ldots,x_{d-1}\) near the corresponding coordinates of \(p\), the function of \(x_d\) is therefore strictly monotone and takes the value \(\lambda\) at the graph. Values on the two sides of that graph lie on opposite sides of \(\lambda\). Every neighborhood of a point on the graph consequently contains points with \(f>\lambda\) and points with \(f<\lambda\), making that point a boundary point of \(L_\lambda\). Conversely, continuity implies that a boundary point of \(L_\lambda\) must have \(f=\lambda\): if \(f>\lambda\), a neighborhood remains above \(\lambda\); if \(f<\lambda\), a neighborhood remains below it. This proves the local claim. \(\square\)

If every point of \(S_\lambda\) has nonzero gradient, this argument applies at every point. The compactness assumption is not needed for the local implicit-function conclusion, but it becomes important for making the geometric bounds uniform over the whole boundary.

Uniform First-Order Geometry Near the Boundary

Theorem: Suppose \(f\) is twice continuously differentiable near a nonempty compact set \(S_\lambda=\{x:f(x)=\lambda\}\), and \(\|\nabla f(p)\|\geq c>0\) for all \(p\in S_\lambda\). Then there are constants \(\delta>0\), \(a>0\), and \(b<\infty\) such that for every \(x\) with \(\operatorname{dist}(x,S_\lambda)<\delta\), $$ a\,\operatorname{dist}(x,S_\lambda) \leq |f(x)-\lambda| \leq b\,\operatorname{dist}(x,S_\lambda). $$

Proof. Because \(S_\lambda\) is compact and lies in the open region where \(f\) is twice continuously differentiable, choose a closed neighborhood of \(S_\lambda\) on which the Hessian is bounded in operator norm by some finite \(M\). For any \(x\) sufficiently close to \(S_\lambda\), compactness ensures there is a nearest point \(p\in S_\lambda\); write \(r=\|x-p\|=\operatorname{dist}(x,S_\lambda)\).

The level set is a smooth hypersurface by the preceding theorem. At a nearest point, the vector \(x-p\) is perpendicular to its tangent space. That tangent space is perpendicular to \(\nabla f(p)\), so \(x-p=t\,n(p)\) for some signed \(t\), with \(|t|=r\). Taylor's theorem along the segment from \(p\) to \(x\), using \(f(p)=\lambda\), gives

$$ f(x)-\lambda =\nabla f(p)^\mathsf{T}(x-p)+R =t\|\nabla f(p)\|+R, \qquad |R|\leq \frac{M}{2}r^2. $$

The lower gradient bound and the triangle inequality now imply \(|f(x)-\lambda|\geq cr-(M/2)r^2\). Choose \(\delta\) small enough that \(M\delta/2\leq c/2\) (if \(M=0\), this restriction is unnecessary). Then the lower bound is at least \((c/2)r\). For the upper bound, let \(C=\sup_{p\in S_\lambda}\|\nabla f(p)\|\), which is finite by compactness. Taylor's theorem gives \(|f(x)-\lambda|\leq Cr+(M/2)r^2\leq (C+M\delta/2)r\). Thus the result holds with \(a=c/2\) and \(b=C+M\delta/2\). \(\square\)

This comparison has a direct geometric interpretation: sufficiently close to a regular compact boundary, a point's density difference from the threshold is proportional to its distance from the boundary, up to fixed multiplicative constants. The constants can be chosen uniformly along the boundary because the gradient cannot approach zero there and the curvature-producing second derivatives remain bounded nearby.

What Compactness Does—and Does Not—Provide

Compactness turns pointwise regularity into uniform control. On a compact level set, a continuous, everywhere nonzero gradient has a strictly positive minimum magnitude, while continuity of the Hessian gives a finite bound in a small closed neighborhood. These uniform constants are what allow a single distance range and a single pair of comparison constants to work all along the boundary.

The result is local to a neighborhood of \(S_\lambda\). It does not assert that every point in the entire domain with density close to \(\lambda\) must be close to the level set. Such a global assertion would require an additional condition excluding distant points whose density values approach \(\lambda\). Keeping that distinction clear prevents local boundary geometry from being mistaken for a global statement about all near-threshold locations.

Common Mistake

  • Assuming a smooth density always has a smooth level boundary. Smoothness of \(f\) alone does not rule out critical points on the level set. At the maximum of the bivariate normal in the worked example, the gradient vanishes and the superlevel set collapses to a point.
  • Using a pointwise gradient bound as if it were automatically uniform. The lower bound used in the theorem relies on continuity and compactness of the level set. Without compactness, a nonzero gradient at every individual point need not have a positive global lower bound.
  • Applying a local comparison globally. The distance comparison is proved only when \(x\) is sufficiently close to \(S_\lambda\). It does not, by itself, exclude distant near-threshold points.
Key takeaway: A compact level set with nonvanishing gradient is a regular hypersurface, and bounded second derivatives make the density's departure from the threshold uniformly comparable to distance near that boundary. Critical thresholds can violate this geometry even for very smooth densities.

Check Your Understanding

Use the definitions and results above to answer the following questions.

  1. Why does compactness turn an everywhere nonzero continuous gradient on \(S_\lambda\) into a uniform positive lower bound?
  2. What role does the implicit function theorem play in showing that a regular level set is locally a hypersurface?
  3. In the Taylor expansion near the boundary, why is the first-order term equal to \(t\|\nabla f(p)\|\)?
  4. Which condition fails at the maximum-density threshold in the bivariate normal example, and what happens to its superlevel set?
  5. Why does the distance comparison theorem not imply that every point with density close to \(\lambda\), anywhere in the domain, is close to \(S_\lambda\)?
Clinical Biostats