Skip to content

Add executable demo notebook: ppstats vs scipy.stats with interactive explorers - #3

Open
reedpen wants to merge 1 commit into
openteams-ai:mainfrom
reedpen:demo-notebook
Open

reedpen wants to merge 1 commit into
openteams-ai:mainfrom
reedpen:demo-notebook

Conversation

@reedpen

@reedpen reedpen commented Jul 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Adds demo/ppstats_demo.ipynb, an executable tour of the full capability story:

  • Kernel source inspectioninspect.getsource on real @guvectorize/@vectorize kernels: the source is plain typed Python.
  • Side-by-side accuracy vs scipy.stats — descriptive reductions and distribution kernels checked with the documented tolerance models: 1e-12 relative for direct-formula kernels on a fixed grid, a purely absolute 2e-7 check for norm_cdf (ppspecial's ndtr bound is absolute), and the bench harness's 1e-9 allowance for random-data cancellation in the reductions (explicitly labeled as such).
  • Two execution modes, one source — interpreted family modules vs the compiled ppstats_native extension, asserted to agree at 1e-13.
  • gufunc semantics(batch, n) reductions and loc/scale broadcasting contrasted with scipy's axis=/broadcast calls.
  • Interactive explorers (ipywidgets) — a distribution explorer (family dropdown + loc/scale sliders, live ppstats/scipy overlay with abs/rel diff and timing readouts) and a performance explorer (size selector 1e3–1e6 + function dropdown, live speedup bars).
  • Static performance summary at N=1e6, honestly including the known loss cases (mean on long vectors, norm_ppf), with perf prose worded as commonly-observed-on-linux-64 rather than absolute claims.

Environment

Ships as a pixi demo feature in its own solve group (scipy, matplotlib, ipywidgets, jupyterlab, nbconvert; python pinned 3.14 to match the compiled extension ABI) — scipy stays out of [project].dependencies and the dev feature, per the working rules. Default/dev lock entries are byte-identical to main. New tasks: demo-build, demo-exec (headless execution check), demo.

pixi run -e demo demo-build
pixi run -e demo demo

Verification

  • pixi install -e demo solves; default/dev solves unchanged
  • pixi run -e demo demo-build → 27 ufuncs registered
  • pixi run -e demo demo-exec → exit 0, zero error outputs (norm_cdf max abs error 9.6e-8 vs 2e-7 allowance)
  • pixi run -e dev test → 198 passed, unchanged profile
  • Committed notebook has cleared outputs; executed copy and built .so are gitignored

… explorers

demo/ppstats_demo.ipynb tours the full capability story: kernel source
inspection, side-by-side accuracy checks against scipy.stats using the
documented tolerance models (absolute for ndtr-backed norm kernels),
interpreted-vs-native agreement, gufunc broadcasting, ipywidgets
distribution and performance explorers, and a static speedup summary
that honestly includes the known loss cases (mean, norm_ppf).

Ships as a pixi 'demo' feature in its own solve group (scipy,
matplotlib, ipywidgets, jupyterlab; python pinned 3.14 to match the
compiled extension ABI) so scipy stays out of the runtime and dev
dependencies. Tasks: demo-build / demo-exec / demo. Headless
execution verified via demo-exec; dev suite unchanged (198 passed).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant