Tutorials › Statistical Learning (Graduate) › The Sandwich Bound for Estimated Level Sets

Level Sets and Cluster Trees · Tutorial 670 of 989

The Sandwich Bound for Estimated Level Sets

Learn how a uniform density error controls estimated level sets through two population level sets, and what this guarantee does—and does not—say about set membership.

Advanced 10 min read

What You'll Learn

  • Define population and estimated density superlevel sets using a consistent threshold convention
  • Prove the sandwich inclusion from a pointwise uniform error bound
  • Identify when the inclusions hold everywhere and when they hold only almost everywhere
  • Apply the bound to concrete density estimates and thresholds
  • Localize disagreements between estimated and population level sets
  • Recognize why the sandwich does not imply equality or geometric closeness

Why a Uniform Error Bound Gives a Set Sandwich

A density estimate is often used by thresholding: include a point when its estimated density is at least a chosen level. The resulting set can differ from the population set because the estimated density is not exact. A uniform error bound gives a direct way to control that difference. It says that every estimated inclusion must be compatible with the true density being no more than a specified amount below the threshold, and every point sufficiently above the threshold must be included by the estimate.

This is a deterministic implication: once the error bound holds, the set inclusions follow without a probability calculation. If the estimate is random, the same implication holds on every outcome for which the uniform bound holds. The guarantee concerns containment between sets, not equality of their boundaries or closeness of their shapes.

Definition: Let \(\mathcal{X}\subseteq\mathbb{R}^d\) be the domain, and let \(f\) and \(\hat f\) be fixed, measurable versions of a population density and its estimate on \(\mathcal{X}\). For a threshold \(t\), define the superlevel sets $$ L_f(t)=\{x\in\mathcal{X}:f(x)\ge t\}, \qquad L_{\hat f}(t)=\{x\in\mathcal{X}:\hat f(x)\ge t\}. $$ A pointwise uniform error bound of size \(\varepsilon\ge 0\) means \(\sup_{x\in\mathcal{X}}|\hat f(x)-f(x)|\le\varepsilon\).

The use of \(\ge\) is part of the convention: points exactly at the threshold belong to the superlevel set. The pointwise form of the error bound matters too. If the available guarantee is only an essential-supremum bound, then the pointwise argument below applies outside a set of Lebesgue measure zero; it does not necessarily give inclusion at every point. We first state and prove the pointwise version.

The Sandwich Theorem

Theorem: If \(f\) and \(\hat f\) are measurable and \(|\hat f(x)-f(x)|\le\varepsilon\) for every \(x\in\mathcal{X}\), then for every real threshold \(\lambda\), $$ L_f(\lambda+\varepsilon) \subseteq L_{\hat f}(\lambda) \subseteq L_f(\lambda-\varepsilon). $$

The two inclusions have different roles. The inner population set contains points whose true density is high enough that even a downward estimation error of size \(\varepsilon\) leaves the estimate at or above \(\lambda\). The outer population set contains every point that could reach the estimated threshold despite an upward error of that size.

Proof. Take any \(x\in L_f(\lambda+\varepsilon)\). By definition, \(f(x)\ge\lambda+\varepsilon\). The error bound implies \(\hat f(x)\ge f(x)-\varepsilon\), so \(\hat f(x)\ge\lambda\). Thus \(x\in L_{\hat f}(\lambda)\), proving the first inclusion. Now take any \(x\in L_{\hat f}(\lambda)\). Then \(\hat f(x)\ge\lambda\), and the error bound implies \(f(x)\ge\hat f(x)-\varepsilon\ge\lambda-\varepsilon\). Hence \(x\in L_f(\lambda-\varepsilon)\), proving the second inclusion. \(\square\)

The non-strict inequalities are important. At the lower edge of the estimated set, the estimate may equal \(\lambda\); at the upper edge of the inner population set, the true density may equal \(\lambda+\varepsilon\). Both points are included under the stated convention, and the proof still applies exactly.

Worked Example: Computing Both Sides of the Sandwich

On \(\mathcal{X}=[0,1]\), let \(f(x)=0.7+0.6x\) and \(\hat f(x)=0.65+0.7x\). Both are nonnegative densities: their integrals on \([0,1]\) are \(0.7+0.3=1\) and \(0.65+0.35=1\). Their difference is \(\hat f(x)-f(x)=0.05(2x-1)\), so $$ \sup_{0\le x\le 1}|\hat f(x)-f(x)|=0.05. $$ Set \(\lambda=1\) and \(\varepsilon=0.05\).

The inner population set is $$ L_f(1.05)=\{x:0.7+0.6x\ge1.05\} =\left[\frac{7}{12},1\right], $$ because \(0.6x\ge0.35\), or \(x\ge7/12\). The estimated set is $$ L_{\hat f}(1)=\{x:0.65+0.7x\ge1\} =\left[\frac12,1\right], $$ because \(0.7x\ge0.35\). The outer population set is $$ L_f(0.95)=\{x:0.7+0.6x\ge0.95\} =\left[\frac{5}{12},1\right], $$ because \(0.6x\ge0.25\). Therefore \(\left[7/12,1\right]\subseteq\left[1/2,1\right]\subseteq\left[5/12,1\right]\), as asserted.

Membership Consequences and a Disagreement Band

The sandwich can also locate every point on which the estimated and population sets disagree at the original threshold. Write \(A=L_f(\lambda)\) and \(\hat A=L_{\hat f}(\lambda)\). If a point belongs to exactly one of these sets, its true density must be near \(\lambda\): far above the threshold it is included by both, and far below it is excluded by both.

Result: Under the same pointwise error bound, $$ A\mathbin{\triangle}\hat A \subseteq \{x\in\mathcal{X}:\lambda-\varepsilon\le f(x)<\lambda+\varepsilon\}, $$ where \(A\mathbin{\triangle}\hat A=(A\setminus\hat A)\cup(\hat A\setminus A)\) is the symmetric difference.

Proof. First suppose \(x\in A\setminus\hat A\). Then \(f(x)\ge\lambda\), while \(\hat f(x)<\lambda\). Since \(f(x)\le\hat f(x)+\varepsilon\), it follows that \(f(x)<\lambda+\varepsilon\). Thus \(\lambda\le f(x)<\lambda+\varepsilon\). Next suppose \(x\in\hat A\setminus A\). Then \(\hat f(x)\ge\lambda\), while \(f(x)<\lambda\). Since \(f(x)\ge\hat f(x)-\varepsilon\), it follows that \(f(x)\ge\lambda-\varepsilon\). Thus \(\lambda-\varepsilon\le f(x)<\lambda\). Both cases place \(x\) in the displayed band, proving the result. \(\square\)

The band’s endpoints reflect the threshold convention. A point with \(f(x)=\lambda-\varepsilon\) can be included by the estimate if its error is upward by exactly \(\varepsilon\), so the lower endpoint is included. A point with \(f(x)=\lambda+\varepsilon\) cannot be omitted by the estimate under the assumed bound, so the upper endpoint is excluded from the disagreement band.

Worked Example: Finding Where the Sets Differ

Use \(f(x)=0.7+0.6x\) and \(\hat f(x)=0.65+0.7x\) on \([0,1]\), with error bound \(\varepsilon=0.05\), but now set \(\lambda=1.1\). The population set is $$ A=L_f(1.1)=\{x:0.7+0.6x\ge1.1\} =\left[\frac{2}{3},1\right]. $$ The estimated set is $$ \hat A=L_{\hat f}(1.1)=\{x:0.65+0.7x\ge1.1\} =\left[\frac{9}{14},1\right], $$ since \(0.45/0.7=9/14\). Therefore \(A\subset\hat A\), and the disagreement is \([9/14,2/3)\).

The density band from the result is $$ \{x:1.05\le0.7+0.6x<1.15\} =\left[\frac{7}{12},\frac{3}{4}\right). $$ Since \(9/14\ge7/12\) and \(2/3<3/4\), the disagreement \([9/14,2/3)\) lies inside this band. The band is a guaranteed region in which disagreement may occur; it need not equal the disagreement itself.

Endpoint Behavior and What the Bound Does Not Say

The shifted levels cannot in general be tightened using only the uniform error bound. The next example checks both boundary cases with valid densities. It also illustrates why the sandwich is not an equality: the estimate may include points that are below the target population level, provided they remain within the uncertainty allowed by \(\varepsilon\).

Worked Example: Boundary Points and a Strictly Wider Middle Set

Let \(\mathcal{X}=[0,1]\), \(f(x)=1+0.2(2x-1)\), and \(\hat f(x)=1\). These are nonnegative densities: \(f(x)=0.8+0.4x\) integrates to \(0.8+0.2=1\), and \(\hat f\) integrates to \(1\). The uniform error is $$ |\hat f(x)-f(x)|=0.2|2x-1|\le0.2, $$ with equality at \(x=0\) and \(x=1\). Take \(\lambda=1\) and \(\varepsilon=0.2\). Then \(L_{\hat f}(1)=[0,1]\), while $$ L_f(1.2)=\{1\}, \qquad L_f(0.8)=[0,1]. $$ Indeed, \(f(x)\ge1.2\) requires \(0.4x\ge0.4\), so \(x=1\); and \(f(x)\ge0.8\) holds throughout the domain. Thus \(\{1\}\subset[0,1]\subset[0,1]\). At \(x=1\), \(f(x)=\lambda+\varepsilon\) and \(\hat f(x)=\lambda\), so the inner inclusion must allow equality at its threshold. At \(x=0\), \(f(x)=\lambda-\varepsilon\) and \(\hat f(x)=\lambda\), so the outer inclusion must allow equality there too.

A frequent mistake is to read the theorem as saying that the estimated set equals the population set, or that every point in the outer set must be estimated as included. The proof gives only the two stated containments. In the example above, every point in \([0,1]\) is estimated as included, although most points do not belong to \(L_f(1.2)\). Reversing either inclusion is also unjustified: the error bound does not say that every point of \(L_f(\lambda-\varepsilon)\) is estimated above \(\lambda\), or that every estimated point has true density at least \(\lambda+\varepsilon\).

Key takeaway: A pointwise uniform density error of at most \(\varepsilon\) guarantees \(L_f(\lambda+\varepsilon)\subseteq L_{\hat f}(\lambda)\subseteq L_f(\lambda-\varepsilon)\). It localizes possible membership disagreements to a band of density values around \(\lambda\), but it does not by itself establish set equality or geometric closeness.

Check Your Understanding

Use the convention that a superlevel set includes points where the function equals its threshold.

  1. If \(|\hat f(x)-f(x)|\le0.03\) everywhere, which two population levels sandwich \(L_{\hat f}(2)\)?
  2. Why does the proof of \(L_f(\lambda+\varepsilon)\subseteq L_{\hat f}(\lambda)\) still work when \(f(x)=\lambda+\varepsilon\)?
  3. For a point in \(L_{\hat f}(\lambda)\setminus L_f(\lambda)\), what lower bound must its true density satisfy?
  4. Why does an essential-supremum error bound generally yield inclusions only outside a null set rather than at every point?
  5. Does the sandwich imply \(L_{\hat f}(\lambda)=L_f(\lambda)\)? Give a reason for your answer.
Clinical Biostats