Repository navigation
Stabilize density estimates near support boundaries - #36
Merged
Merged
Conversation
Contributor
Author
added 19 commits
August 25, 2026 11:07
tnagler
force-pushed
the
boundary-stabilization
branch
from
August 25, 2026 09:07
5f61a94 to
805abce
Compare
tvatter
reviewed
Aug 26, 2026
tvatter
reviewed
Aug 26, 2026
Contributor
|
Let's go for this version |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Boundary-repair estimator
This PR changes continuous fits with known finite support in two steps.
For a one-sided support, write$d(x)$ for distance from the finite endpoint,$s$ be the weighted median observed distance, and set
$\epsilon=10^{-5}s$ . The transformed bulk estimator uses an endpoint-anchored,$\lambda=1/4$ :
let
scaled member of the Box-Cox family with power parameter
This Box-Cox transform replaces the previous log transform and makes the
construction scale equivariant. Two-sided fits retain the regularized probit
bulk transform.
Each finite endpoint is then classified independently from its first
$k\simeq2\sqrt{n_e}$ order statistics. In the unweighted case,
Endpoints consistent with a finite nonzero limiting density receive a boundary
expert. Exploding, vanishing, ambiguous, and degenerate endpoints retain the
bulk. The expert is a Gaussian local-linear equivalent-kernel estimate with an
automatically selected bandwidth on the original scale. The selector uses all
positive-weight observations on bounded support and the closest 75% by row
count on one-sided support. The two required Gaussian convolutions are
evaluated on a shared 256-bin FFT grid.
Let$F_B$ be the normalized bulk CDF,
Selected lower and upper experts receive the biweight fusion weights
$w_L(x)=g{F_B(x)}$ and $w_U(x)=g{1-F_B(x)}$ , giving
The result is clamped at zero and normalized. The same boundary expert is used
for bulk degrees 0, 1, and 2. EDF is a conditional influence-trace
approximation that holds the classifier, selected bandwidths, fusion weights,
clamps, and normalization fixed.
Validation design
The primary benchmark is the actual pre-PR package at parent commit
$n\in{25,100,1000,2000}$ and degrees 0, 1, and 2.
7faec53with C++ commit
b16d514: log transform for one-sided support and probit fortwo-sided support. The experiment used 200 paired replications for
Lomax$(2)$, with lower/upper reflections and scales
Beta$(2,0.75)$, Beta$(0.75,0.75)$, and Beta$(2,2)$.
is the outer 10% probability mass at each finite endpoint.
The tables below use scale 1; reflected one-sided results agree to numerical
precision. Entries are candidate/baseline ratios, so values below 1 favor the
PR. Parentheses are paired Monte Carlo standard errors.
Global ISE ratio, averaged over families
Boundary ratio, averaged over families
Against the unrepaired new bulk, averaged global ISE ratios range from
0.83--0.94 for degree 0, 0.73--0.88 for degree 1, and 0.87--0.92 for degree 2
on one-sided support. The corresponding bounded ratios are 0.93--0.95,
0.82--0.86, and 0.88--0.94.
Family-level global / boundary ISE ratios
One-sided, degree 0
One-sided, degree 1
One-sided, degree 2
Two-sided, degree 0
Two-sided, degree 1
Two-sided, degree 2
Bias, variance, classification, and scale
The repair primarily reduces variance, with deliberate boundary bias. Against
pre-PR at scale 1, aggregate global variance ratios are 0.38--0.62 one-sided
for degree 0, 0.39--0.56 for degree 1, and 0.20--0.24 for degree 2. Bounded
ratios are 0.96--0.98, 0.84--0.87, and 0.87--0.96, respectively. This matches
the visual goal: substantially calmer one-sided endpoints and moderate
smoothing on bounded support.
Classifier behavior becomes appropriately conservative with sample size. For$n=100/2000$ are 58%/78%
$n=100$ to 0% at $n\geq1000$ .
one-sided finite targets, selection rates at
(Exponential), 75%/82% (half-normal), and 56%/76% (Lomax). False finite
selection falls from 22% to 4% for Gamma$(0.75)$ and from 38% to 0% for
Gamma$(2)$. For Uniform, either endpoint is selected in 90%/98% and both in
51%/71% of samples. Beta$(2,2)$ falls from 4.5% both-endpoint selection at
For Exponential samples at$n=100$ , the 5%--95% range of the estimated value
at the endpoint is 0.64--1.34 when the expert is selected, compared with
0.01--49.6 when the classifier retains the raw bulk. Thus the expert delivers
the intended visual stabilization when selected; remaining extreme endpoint
values are primarily classifier false negatives.
Coarse runtime
Median end-to-end R fit times for the default degree-2 estimator are below.
Less common paths and numerical checks
estimand, bandwidth selector, effective sample size, and EDF approximation.
Tests cover weight rescaling and zero-weight-row invariance.
experts retain their original-scale automatic bandwidth; the public
multiplier scales both. This unusual path has focused regression tests but
was not included in the full Monte Carlo sweep.
boundary_repair=falserecovers the transformed bulk and skips allexpert work.
quantile round trips, support truncation, reflection, scales
about 0.08--0.30 EDF units for deterministic Uniform/Exponential examples;
the largest checked discrepancy was 0.84 for Beta$(1,2)$ at