bc-cpit
Conditional generators (diffusion, ensembles, simulators) often return a finite sample vector
\hat{\mathbf{Y}}(x)
=
\left(
\hat{Y}^{(1)}(x),
\ldots,
\hat{Y}^{(m)}(x)
\right)
\sim
\hat{Q}^{(m)}_x
with no tractable likelihood. Those sample clouds can be biased and poorly calibrated, and standard conformal tools mainly return a fixed-level set—not a predictive CDF you can query for arbitrary quantiles, exceedance probabilities, or tail losses.
bc-cpit is a split-sample post-processing pipeline:
- Bias correction — fit an affine location–scale map on a held-out bias split (global, or x-dependent via GAM).
- Conformal PIT calibration — calibrate randomized PITs on a calibration split; represent the corrected law as a weighted empirical distribution on the generator order statistics.
From the calibrated law you get threshold-coherent probabilities, quantiles, central / highest-density intervals, and calibrated resamples. An optional PIT-centrality wrapper adds nested intervals with finite-sample marginal coverage under exchangeability.
This package does not retrain the generator; it recalibrates whatever samples you already have.
Install
pip install bc-cpit
Development:
git clone https://github.com/egpivo/bc-cpit.git
cd bc-cpit
pip install -e ".[dev]"
Quick start
from cpit.bc import fit_global_affine, apply_affine
from cpit import fit_conformal_calibrator, get_weighted_samples_at_x
from cpit import quantile_from_weighted_samples, central_interval_from_weighted_samples
# 1. Bias correction
params = fit_global_affine(y_bias, y_bias_samples)
# 2. Conformal calibration
cal_samples_adj = [apply_affine(s, params) for s in cal_samples]
_, c_hat = fit_conformal_calibrator(cal_samples_adj, y_cal)
# 3. Inference
y_pts, weights = get_weighted_samples_at_x(y_test_samples, params, c_hat)
q80 = quantile_from_weighted_samples(y_pts, weights, 0.80)
lo, hi = central_interval_from_weighted_samples(y_pts, weights, alpha=0.10)
x-dependent (GAM) correction:
from cpit.bc import fit_x_dependent_affine_gam
params_gam = fit_x_dependent_affine_gam(x_bias, y_bias, y_bias_samples)
y_pts, weights = get_weighted_samples_at_x(y_test_samples, params_gam, c_hat, x=x_test)
High-level pipeline:
from cpit.pipeline import run_pipeline, predict_interval
state = run_pipeline(X, y, generator_fn)
lo, hi = predict_interval(state, X_test, y_samples_test, alpha=0.10)
Reproduce paper results
make test # unit tests
make run-sim # Designs 1/2/3 simulations (§5)
make pit-figures # PIT histogram figures
make run-wb2 # WB2 application: Taiwan + Europe (§6)
Citation
If you use this package, please cite:
Wang, W.-T., Tzeng, S., Fan, Y.-T., & Huang, H.-C. (2026). Calibrated Predictive Distributions from Sample-Based Generators. arXiv:2609.19035.
@article{wang2026calibrated,
title = {Calibrated Predictive Distributions from Sample-Based Generators},
author = {Wang, Wen-Ting and Tzeng, ShengLi and Fan, Yu-Ting and Huang, Hsin-Cheng},
journal = {arXiv preprint arXiv:2609.19035},
year = {2026},
url = {https://arxiv.org/abs/2609.19035}
}
License
MIT — see LICENSE.
Metadata
Release files for bc-cpit 1.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| bc_cpit-1.0.1.tar.gz | 37.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| bc_cpit-1.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 65.8 kB
Release files / bc_cpit-1.0.1.tar.gz
| Download URL | bc_cpit-1.0.1.tar.gz |
|---|---|
| Size | 37.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d4ae7f775484b42f4e65b94049feda40465dae364dbf03e7030b714fd4edc4de
|
|
BLAKE2b-256 checksum How to use checksums |
ad00567ce32ffed5ece9a50a5975b7bd80541eca76ed3fbede559f34ca35d088
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Release files / bc_cpit-1.0.1-py3-none-any.whl
| Download URL | bc_cpit-1.0.1-py3-none-any.whl |
|---|---|
| Size | 28.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
87f9423469e8607857d8ee79acab856d3dccc32b9e74fba08a67537ce634f832
|
|
BLAKE2b-256 checksum How to use checksums |
cc8fbe60ccaa2afa6fe046610a5bb086e40ba718cd60981db911a10cf50822f3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|