Skip to main content

Module height_predictor

Module height_predictor 

Source
Expand description

Bayesian height prediction with conformal bounds for virtualized lists. Bayesian height prediction with conformal bounds for virtualized lists.

Predicts unseen row heights to pre-allocate scroll space and avoid scroll jumps when actual heights are measured lazily.

§Mathematical Model

§Bayesian Online Estimation

Maintains a Normal-Normal conjugate model per item category:

Prior:     μ ~ N(μ₀, σ₀²/κ₀)
Likelihood: h_i ~ N(μ, σ²)
Posterior:  μ | data ~ N(μ_n, σ²/κ_n)

where:
  κ_n = κ₀ + n
  μ_n = (κ₀·μ₀ + n·x̄) / κ_n
  σ²  estimated via running variance (Welford's algorithm)

§Conformal Prediction Bounds

Given a calibration set of (predicted, actual) residuals, the conformal interval is:

[μ_n - q_{1-α/2}, μ_n + q_{1-α/2}]

where q is the empirical quantile of |residuals|. This provides distribution-free coverage: P(h ∈ interval) ≥ 1 - α.

§Failure Modes

ConditionBehaviorRationale
No measurementsReturn default heightCold start fallback
n = 1Wide interval (use prior σ)Insufficient data
All same heightσ → 0, interval collapsesHomogeneous data
Actual > boundAdjust + record violationExpected at rate α

Structs§

HeightPrediction
A prediction with conformal bounds.
HeightPredictor
Bayesian height predictor with conformal bounds.
PredictorConfig
Configuration for the height predictor.