Repository navigation
[DOCS] Add a gallery example comparing two tail estimators on shared bootstrap draws - #1672
Conversation
…p draws The example fits TailCurve and TailBondy to the same 1,000 BootstrapODPSample draws of genins and to draws from a second seed. The shared-draw difference in total IBNR has a standard deviation of 1,540,822 against 4,728,455 for independent draws, a ratio of 0.326, close to sqrt(1 - rho) at a correlation of 0.885. A second table runs 200, 1,000 and 2,000 draws to show that the ratio stays near a third while the standard error of the mean difference falls from 105,259 to 35,350. Developed with an AI assistant (Árbol, running Muse).
Pyright Type CompletenessView the full Project (full
Other symbols referenced but not exported by
Symbols without documentation:
Patch (exported symbols added or changed by this PR): no exported symbol type-completeness changes detected. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1672 +/- ##
=======================================
Coverage 95.03% 95.03%
=======================================
Files 100 100
Lines 6471 6471
Branches 819 819
=======================================
Hits 6150 6150
Misses 203 203
Partials 118 118
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
The page now compares two tail estimators, TailBondy and TailCurve, and its title and gallery card say so. The deterministic baselines come first, with a sentence on what they are for. The text names `sims` as the shared draws and `other` as the draws from a second seed. The old discussion section is now two. The first prints the standard deviation of each method and of each difference, 1,540,822 on shared draws against 4,728,455 on independent draws. The second gives the variance identity and the correlations, 0.885 on shared draws and 0.011 on independent draws. A scatter plot of TailCurve against TailBondy total IBNR, with a line of equal totals, shows the two correlations before the histogram. Developed with an AI assistant (Árbol, running Muse).
|
Thanks for the close read. eb9e6d5 takes all five points in order.
The standard deviations and correlationsimport numpy as np
import chainladder as cl
genins = cl.load_sample("genins")
def total_ibnr(triangles, tail):
developed = tail.fit_transform(cl.Development().fit_transform(triangles))
return cl.Chainladder().fit(developed).ibnr_.sum("origin").values.flatten()
sims = cl.BootstrapODPSample(n_sims=1000, random_state=42).fit_transform(genins)
other = cl.BootstrapODPSample(n_sims=1000, random_state=7).fit_transform(genins)
curve = total_ibnr(sims, cl.TailCurve())
bondy = total_ibnr(sims, cl.TailBondy())
bondy_other = total_ibnr(other, cl.TailBondy())
print("sd, same draws", round((bondy - curve).std(ddof=1)))
print("sd, independent draws", round((bondy_other - curve).std(ddof=1)))
print("correlation, same draws", round(np.corrcoef(curve, bondy)[0, 1], 3))
print("correlation, independent draws", round(np.corrcoef(curve, bondy_other)[0, 1], 3))(This comment was written with Árbol, an AI assistant, under my direction.) |





Summary of Changes
Adds
docs/gallery/plot_paired_bootstrap.ipynb, a gallery example that fits two tail estimators to the sameBootstrapODPSampledraws and looks at the difference on each draw. It compares TailCurve with TailBondy ongenins, once on shared draws and once on draws from a second seed. It shows the identity Var(B − C) = Var B + Var C − 2 Cov(B, C), the ratio near √(1 − ρ), and that more draws shrink the standard error of the mean difference but leave the gap between the two standard deviations in place. The gallery index gets a card and a toctree entry, anddocs/images/plot_paired_bootstrap.pngis the card image.Related GitHub Issue(s)
Closes #1664
AI/LLM Usage
I used Árbol, an AI assistant running on Muse, under my direction to write the notebook, run it and draft this description. I reviewed the notebook and its numbers.
Additional Context for Reviewers
Results on main 687e329, 1,000 draws with seeds 42 and 7:
The correlation of the two totals across shared draws is 0.885, √(1 − ρ) is 0.338 and the observed ratio of standard deviations is 0.326.
pytest --nbmakepasses on the notebook, and ruff 0.16.1 check and format pass.jb build docswith execution off succeeds. The new page adds no warnings, and the link toplot_bootstrap_comparison, theshapland2016citation and the gallery card all resolve.fit_transformcall feeding both tail estimators. [FEAT] Record the seed each random draw used asrandom_state_, and handlerandom_stateas documented #1605 changes how estimators recordrandom_state, and nothing in this notebook depends on that change.Submitter's Checklist
[FIX],[FEAT],[DOCS],[TST],[CHORE], or[BRK]).Reviewer's Checklist