telescopic 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- telescopic-0.1.0/.gitignore +39 -0
- telescopic-0.1.0/CHANGELOG.md +583 -0
- telescopic-0.1.0/CITATION.cff +41 -0
- telescopic-0.1.0/LICENSE +21 -0
- telescopic-0.1.0/PKG-INFO +129 -0
- telescopic-0.1.0/README.md +83 -0
- telescopic-0.1.0/benchmarks/__init__.py +1 -0
- telescopic-0.1.0/benchmarks/compare.py +299 -0
- telescopic-0.1.0/benchmarks/estimator.py +314 -0
- telescopic-0.1.0/benchmarks/hierarchical.py +150 -0
- telescopic-0.1.0/benchmarks/logistic.py +101 -0
- telescopic-0.1.0/benchmarks/logistic_reference.py +121 -0
- telescopic-0.1.0/benchmarks/parallax.py +158 -0
- telescopic-0.1.0/benchmarks/registered.py +108 -0
- telescopic-0.1.0/benchmarks/research.py +211 -0
- telescopic-0.1.0/benchmarks/results/logistic-300.json +673 -0
- telescopic-0.1.0/benchmarks/results/logistic-6.json +85 -0
- telescopic-0.1.0/benchmarks/run.py +257 -0
- telescopic-0.1.0/benchmarks/supernova.py +245 -0
- telescopic-0.1.0/benchmarks/targets.py +327 -0
- telescopic-0.1.0/benchmarks/uncoupled.py +140 -0
- telescopic-0.1.0/pyproject.toml +163 -0
- telescopic-0.1.0/src/telescopic/__init__.py +44 -0
- telescopic-0.1.0/src/telescopic/_gradient_check.py +317 -0
- telescopic-0.1.0/src/telescopic/_io.py +421 -0
- telescopic-0.1.0/src/telescopic/_linalg.py +64 -0
- telescopic-0.1.0/src/telescopic/_parallel.py +468 -0
- telescopic-0.1.0/src/telescopic/_progress.py +76 -0
- telescopic-0.1.0/src/telescopic/_random.py +261 -0
- telescopic-0.1.0/src/telescopic/_types.py +231 -0
- telescopic-0.1.0/src/telescopic/couplings.py +451 -0
- telescopic-0.1.0/src/telescopic/diagnostics.py +551 -0
- telescopic-0.1.0/src/telescopic/engine.py +1030 -0
- telescopic-0.1.0/src/telescopic/estimators.py +218 -0
- telescopic-0.1.0/src/telescopic/examples.py +315 -0
- telescopic-0.1.0/src/telescopic/initial.py +218 -0
- telescopic-0.1.0/src/telescopic/kernels/__init__.py +35 -0
- telescopic-0.1.0/src/telescopic/kernels/base.py +654 -0
- telescopic-0.1.0/src/telescopic/kernels/gibbs.py +267 -0
- telescopic-0.1.0/src/telescopic/kernels/hmc.py +294 -0
- telescopic-0.1.0/src/telescopic/kernels/independence.py +214 -0
- telescopic-0.1.0/src/telescopic/kernels/mala.py +102 -0
- telescopic-0.1.0/src/telescopic/kernels/metropolis.py +632 -0
- telescopic-0.1.0/src/telescopic/kernels/mixture.py +228 -0
- telescopic-0.1.0/src/telescopic/kernels/random_walk.py +126 -0
- telescopic-0.1.0/src/telescopic/measure.py +139 -0
- telescopic-0.1.0/src/telescopic/plotting.py +354 -0
- telescopic-0.1.0/src/telescopic/py.typed +0 -0
- telescopic-0.1.0/src/telescopic/results.py +1174 -0
- telescopic-0.1.0/src/telescopic/sampler.py +1285 -0
- telescopic-0.1.0/src/telescopic/target.py +351 -0
- telescopic-0.1.0/src/telescopic/testing.py +324 -0
- telescopic-0.1.0/src/telescopic/tuning.py +454 -0
- telescopic-0.1.0/src/telescopic/warnings.py +43 -0
- telescopic-0.1.0/tests/_frozen_kernels.py +101 -0
- telescopic-0.1.0/tests/conftest.py +17 -0
- telescopic-0.1.0/tests/references.py +163 -0
- telescopic-0.1.0/tests/test_benchmark_compare.py +221 -0
- telescopic-0.1.0/tests/test_benchmark_estimator.py +107 -0
- telescopic-0.1.0/tests/test_benchmark_hierarchical.py +59 -0
- telescopic-0.1.0/tests/test_benchmark_logistic.py +65 -0
- telescopic-0.1.0/tests/test_benchmark_parallax.py +57 -0
- telescopic-0.1.0/tests/test_benchmark_registered.py +52 -0
- telescopic-0.1.0/tests/test_benchmark_research.py +52 -0
- telescopic-0.1.0/tests/test_benchmark_supernova.py +61 -0
- telescopic-0.1.0/tests/test_benchmark_targets.py +97 -0
- telescopic-0.1.0/tests/test_benchmark_uncoupled.py +148 -0
- telescopic-0.1.0/tests/test_couplings.py +403 -0
- telescopic-0.1.0/tests/test_diagnostics.py +472 -0
- telescopic-0.1.0/tests/test_docstrings.py +41 -0
- telescopic-0.1.0/tests/test_engine.py +800 -0
- telescopic-0.1.0/tests/test_estimators.py +183 -0
- telescopic-0.1.0/tests/test_examples.py +174 -0
- telescopic-0.1.0/tests/test_gradient_check.py +307 -0
- telescopic-0.1.0/tests/test_initial.py +117 -0
- telescopic-0.1.0/tests/test_io.py +213 -0
- telescopic-0.1.0/tests/test_kernels.py +1582 -0
- telescopic-0.1.0/tests/test_measure.py +111 -0
- telescopic-0.1.0/tests/test_metropolis.py +380 -0
- telescopic-0.1.0/tests/test_parallel.py +833 -0
- telescopic-0.1.0/tests/test_plotting.py +282 -0
- telescopic-0.1.0/tests/test_random.py +170 -0
- telescopic-0.1.0/tests/test_results.py +688 -0
- telescopic-0.1.0/tests/test_sampler.py +1455 -0
- telescopic-0.1.0/tests/test_statistics.py +386 -0
- telescopic-0.1.0/tests/test_target.py +416 -0
- telescopic-0.1.0/tests/test_testing.py +224 -0
- telescopic-0.1.0/tests/test_tuning.py +495 -0
- telescopic-0.1.0/tests/test_validation.py +175 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
|
|
9
|
+
# Tools
|
|
10
|
+
.pytest_cache/
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.hypothesis/
|
|
14
|
+
.coverage
|
|
15
|
+
coverage.xml
|
|
16
|
+
htmlcov/
|
|
17
|
+
|
|
18
|
+
# Docs
|
|
19
|
+
docs/_build/
|
|
20
|
+
docs/jupyter_execute/
|
|
21
|
+
docs/api/
|
|
22
|
+
|
|
23
|
+
# Local state of agents: everything under .claude/ but the shared rules, and the
|
|
24
|
+
# working folders of tasks shared between agents
|
|
25
|
+
.claude/*
|
|
26
|
+
!.claude/rules/
|
|
27
|
+
.agents/swarm/
|
|
28
|
+
.agents/handoff.md
|
|
29
|
+
|
|
30
|
+
# Editors and OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
.idea/
|
|
33
|
+
.vscode/
|
|
34
|
+
|
|
35
|
+
# The review hub data, built by notes/review/hub/build.py
|
|
36
|
+
notes/review/hub/review-data.json
|
|
37
|
+
|
|
38
|
+
# The rows that the experiments' run scripts write
|
|
39
|
+
notes/experiments/_rows/
|
|
@@ -0,0 +1,583 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-11-29
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Configurable warmed-reference starting width and validated variance references
|
|
12
|
+
for the 51-dimensional parallax case (#90).
|
|
13
|
+
|
|
14
|
+
- Registered meeting launcher for all benchmark dimensions and mixture variants (#90).
|
|
15
|
+
|
|
16
|
+
- Convergence-gated uncoupled variance references for benchmarks without exact draws
|
|
17
|
+
(#90).
|
|
18
|
+
- Complete half-space and quadrant probability reporting for the mixture benchmarks
|
|
19
|
+
(#90).
|
|
20
|
+
|
|
21
|
+
- Multi-case comparison of frozen random walk and tuned jittered HMC with separate
|
|
22
|
+
setup and sampling evaluation counts (#90).
|
|
23
|
+
- Synthetic supernova and parallax benchmarks with independent quadrature references
|
|
24
|
+
(#90).
|
|
25
|
+
|
|
26
|
+
- Six- and 300-parameter logistic benchmarks with independent Pólya-Gamma reference
|
|
27
|
+
moments and Monte Carlo standard errors (#90).
|
|
28
|
+
|
|
29
|
+
- Centered normal-means benchmark with one-dimensional quadrature and exact posterior
|
|
30
|
+
draws at the eight- and hundred-group sizes (#90).
|
|
31
|
+
|
|
32
|
+
- Four-mode benchmark with a curved component and exact quadrant probabilities (#90).
|
|
33
|
+
|
|
34
|
+
- Fixed-replicate coverage, warnings, and cost-normalized variance summaries for the
|
|
35
|
+
frozen random-walk benchmark (#90).
|
|
36
|
+
|
|
37
|
+
- Evaluation-capped benchmark pilot for the frozen random walk, including raw pair
|
|
38
|
+
records and censoring-aware meeting-cost quantiles (#90).
|
|
39
|
+
|
|
40
|
+
- Exact synthetic benchmark references for the rotated Gaussian, banana, funnel, and
|
|
41
|
+
two-mode Gaussian mixture (#90).
|
|
42
|
+
|
|
43
|
+
- Per-replicate random streams keyed by the root seed, a namespace and the replicate
|
|
44
|
+
index. Each replicate reads its normals and uniforms in order from two child generators,
|
|
45
|
+
buffered for lockstep batches, so no batch layout or buffer width changes a number.
|
|
46
|
+
- Warning classes `TelescopicWarning`, `ConvergenceWarning` and `InputWarning`.
|
|
47
|
+
- Coupling primitives: the reflection-maximal coupling of Gaussians, the rejection maximal
|
|
48
|
+
coupling with the bounded-variance `eta` option, and the maximal coupling of discrete
|
|
49
|
+
distributions (`telescopic.couplings`); `telescopic.testing.fixed_draws` to inject
|
|
50
|
+
random numbers in tests, and `telescopic.testing.random_draws` for fresh ones.
|
|
51
|
+
- `Target` with a batched interface over scalar or vectorized log-densities and gradients;
|
|
52
|
+
initial distributions `Normal`, `Uniform`, `Empirical` and `as_initial`.
|
|
53
|
+
- Kernels with their couplings: `RandomWalk` (reflection-maximal or maximal proposals),
|
|
54
|
+
`Independence` with a `MultivariateT` proposal, and `Mixture`. A row's transition does
|
|
55
|
+
not depend on the other rows of its batch.
|
|
56
|
+
- The engine (`telescopic.engine.run`): replicates of coupled chains in lockstep lanes
|
|
57
|
+
with refill, exact meeting detection, the lag-$L$ and thinned estimator weights, signed
|
|
58
|
+
measures, distances between the chains and censoring. A replicate's output does not
|
|
59
|
+
depend on the number of lanes, bitwise for a log-density evaluated point by point. The
|
|
60
|
+
output records the run's settings and root seed, which `Result` and `merge` read.
|
|
61
|
+
- `SignedMeasure`, the unbiased covariance estimator and quantiles of signed measures by
|
|
62
|
+
isotonic projection (`telescopic.measure`, `telescopic.estimators`).
|
|
63
|
+
- `Result` with estimates and confidence intervals for any test function, unbiased
|
|
64
|
+
covariances, quantiles, credible intervals and signed histograms; total variation
|
|
65
|
+
bounds from the meeting times and 1-Wasserstein bounds from the distances between the
|
|
66
|
+
chains; a summary table; and the warnings of the specification (`telescopic.results`,
|
|
67
|
+
`telescopic.diagnostics`).
|
|
68
|
+
- Automatic tuning and the sampler: adaptive Metropolis pilots whose chains share their
|
|
69
|
+
adaptation, set the kernels' unset parameters and warn when they disagree; the choice
|
|
70
|
+
of `k`, `m` and the lag from pilot meeting times; `CoupledSampler` and
|
|
71
|
+
`telescopic.sample`, whose runs warn about the conditions of the specification.
|
|
72
|
+
- Gradient and Gibbs kernels: `MALA` and `HMC` (with a random-walk meeting step) with
|
|
73
|
+
the reflection-maximal coupling, tuned by dual averaging; `Gibbs` with maximal,
|
|
74
|
+
common-random-number and two-scale couplings of user-written conditionals, and
|
|
75
|
+
`Target(log_prob=None)` for kernels that need no log-density. Kernels declare what
|
|
76
|
+
they evaluate (`needs_grad`, `needs_log_prob`) and check a target for it
|
|
77
|
+
(`check_target`).
|
|
78
|
+
A kernel's `step` returns acceptance probabilities.
|
|
79
|
+
- Parallel runs: `pool=` takes a number of worker processes, an executor or a pool with
|
|
80
|
+
`map`, and gives the same replicates as a run in-process, bitwise for a log-density
|
|
81
|
+
evaluated point by point. The first Ctrl-C lets the
|
|
82
|
+
replicates in progress finish and returns a result flagged `interrupted`, which the
|
|
83
|
+
sampler's next run completes; the second stops at once. `progress=` shows a tqdm bar
|
|
84
|
+
or lines on stderr. The `parallel` extra installs cloudpickle, which ships functions
|
|
85
|
+
defined in notebooks to the workers.
|
|
86
|
+
- `n_workers=` on `sample` and `CoupledSampler` states the number of workers of an
|
|
87
|
+
executor or a pool of your own. A pool that does not report its size, such as a
|
|
88
|
+
cluster's, was counted as having as many workers as this process may use CPUs, which
|
|
89
|
+
left its other workers idle. The argument replaces a reported size, and with a
|
|
90
|
+
log-density evaluated point by point it changes no replicate.
|
|
91
|
+
- `log_prob_and_grad=` on `sample`, `CoupledSampler` and `Target`, in place of `grad`,
|
|
92
|
+
takes a function that returns the log-density and its gradient together, such as
|
|
93
|
+
JAX's `value_and_grad`, and is called once where `log_prob` and `grad` were called one
|
|
94
|
+
after the other. `log_prob` is still required, for the evaluations that need no
|
|
95
|
+
gradient, and a run gives the same numbers and counts as with the two functions when
|
|
96
|
+
they return the same numbers.
|
|
97
|
+
- A pool's chunks hold at most 1,024 replicates. Above 4,096 replicates per worker, four
|
|
98
|
+
chunks per worker grew with the run, to 62,500 replicates each for 1,000,000 on 4
|
|
99
|
+
workers; now a worker's memory, the result it sends back and the steps of the progress
|
|
100
|
+
bar stay bounded. This process still holds every replicate.
|
|
101
|
+
- `Result.save` and `Result.load` (a versioned `.npz` file, without pickle); joint
|
|
102
|
+
signed histograms of several coordinates (`Result.histogram`); plots of meeting times,
|
|
103
|
+
the TV bound, signed marginals and corner plots (`telescopic.plotting`, with
|
|
104
|
+
matplotlib, and the `Result.plot_*` methods, on new or given axes); example targets
|
|
105
|
+
with exact moments (`telescopic.examples`); and `telescopic.testing.check_coupling`,
|
|
106
|
+
which checks a custom kernel's coupling, its meetings and its cached evaluations.
|
|
107
|
+
- A slow tier of statistical tests (`pytest -m ""`): unbiasedness of every kernel family,
|
|
108
|
+
interval coverage, TV bounds against exact distances, published meeting times and
|
|
109
|
+
calibration over the prior. `benchmarks/run.py` times the setups of the
|
|
110
|
+
specification's performance targets. The tuning pilot runs of order d² steps beyond 20
|
|
111
|
+
dimensions, and the variance warning needs one replicate holding more than half the
|
|
112
|
+
variance; both were measured against their alternatives.
|
|
113
|
+
- `import telescopic` imports every public submodule but `plotting`, and `progress=True`
|
|
114
|
+
draws tqdm's text bar, in notebooks too.
|
|
115
|
+
- `Result.diagnostics()` and the summary report the values behind two warnings, the tail
|
|
116
|
+
index of the meeting times and the largest share of one replicate in a variance.
|
|
117
|
+
- Documentation: a Start section, how-to guides, six tutorials executed when the site is
|
|
118
|
+
built, a theory page, the API reference, reference pages and a citing page.
|
|
119
|
+
- The documentation site is published at <https://joshspeagle.com/telescopic/> from each
|
|
120
|
+
push to `main`.
|
|
121
|
+
- The documentation site has its own theme and identity: the Focus mark, two chain colors
|
|
122
|
+
that mean the two chains, Red Hat type served with the site, light and dark themes, a
|
|
123
|
+
landing page with a coupled pair drawn by telescopic itself, and navigation by section
|
|
124
|
+
(Start, Tutorials, How-to guides, Theory, Reference, Project). Every plot of the
|
|
125
|
+
executed pages shares one style. The design records are no longer built into the site.
|
|
126
|
+
- Each tutorial has one title in the sidebar, on its page and in the pager, and the
|
|
127
|
+
comparison with emcee is part of Coming from emcee, under Start. The tutorials are
|
|
128
|
+
ordered as a learning path, with the failure modes last, and the pager is their only
|
|
129
|
+
"next" link.
|
|
130
|
+
- Warnings on the executed pages print as their class and message, without the path of
|
|
131
|
+
the notebook's temporary file, and wrap within the column.
|
|
132
|
+
- Every figure on the executed pages has alternative text and a caption.
|
|
133
|
+
- A Concepts section explains the method without code, one idea per page with its
|
|
134
|
+
figures: why a burn-in biases MCMC, two chains that meet, the telescoping
|
|
135
|
+
correction, signed measures, not samples, error bars from replicates and what
|
|
136
|
+
replaces R-hat and ESS, and meeting times and the distance to stationarity.
|
|
137
|
+
- Two Start pages: What telescopic does, without code, says what problem the package
|
|
138
|
+
solves, what it returns and what it does not do; Is telescopic right for my problem?
|
|
139
|
+
places a problem among good and poor fits, each with its reason and a link to the page
|
|
140
|
+
that holds the fact.
|
|
141
|
+
- Three Reference pages: a Glossary of the package's terms, linked from each term's first
|
|
142
|
+
use on the pages of the other sections but Theory; Notation, which maps each
|
|
143
|
+
symbol of the theory page to its argument or attribute; and an FAQ whose answers link
|
|
144
|
+
to the page that holds each fact.
|
|
145
|
+
- Two how-to guides: Troubleshoot chains that do not meet, indexed by the error or warning
|
|
146
|
+
a run shows, with its cause, a check in code and the fix, and a chart from each warning
|
|
147
|
+
to its remedy; and Make a run faster, which gives each lever with its effect, a figure
|
|
148
|
+
of a replicate's cost, and a table of times measured by `benchmarks/run_faster.py`.
|
|
149
|
+
- A Gallery section of worked examples, executed when the site is built, each ending
|
|
150
|
+
with its summary, a figure against a known or reference answer, and what its warnings
|
|
151
|
+
say: the radial-velocity orbit of an exoplanet; a hierarchical model with the three
|
|
152
|
+
Gibbs couplings; gradients from JAX, for which the `docs` dependency group adds JAX;
|
|
153
|
+
Neal's funnel, which compares the random walk, HMC and a change of coordinates; and
|
|
154
|
+
Checking the burn-in of an existing sampler, which couples a Metropolis sampler of
|
|
155
|
+
one's own and chooses a burn-in from the total variation bound.
|
|
156
|
+
- Figures on existing pages: the automatic pipeline (Settings), what a `Result` holds,
|
|
157
|
+
a pool's chunks and their random streams (Parallel runs), coupled HMC trajectories and
|
|
158
|
+
a meeting step (Choose a kernel), what the lag and `k` trade (Choosing k, m and the
|
|
159
|
+
lag), the estimates of Unbiased on average, telescopic beside emcee, and the two-mode
|
|
160
|
+
target with its two initial distributions; Write a kernel adds a template of every
|
|
161
|
+
member a kernel needs and a figure of the marginal check.
|
|
162
|
+
- The API reference is an index of one-line summaries grouped by section, with a page for
|
|
163
|
+
each class, its attributes and methods, a page for `sample`, and a page for each module
|
|
164
|
+
that the index lists, its functions and a table of its classes. The page of a class with
|
|
165
|
+
two or more members lists them under "On this page".
|
|
166
|
+
- The API reference cites no internal requirement or decision numbers; where such a
|
|
167
|
+
citation carried meaning, it links the page that explains it.
|
|
168
|
+
- The docstring of `telescopic.sample` describes each of its parameters, and that of
|
|
169
|
+
`Estimate` its `level`.
|
|
170
|
+
- The docstrings of `sample`, `CoupledSampler.run`, `Result.estimate`, `Result.summary`,
|
|
171
|
+
each kernel class and `testing.check_coupling` end with a short example, which the
|
|
172
|
+
tests run.
|
|
173
|
+
- Every parameter that a docstring lists has a description, and the strict documentation
|
|
174
|
+
build fails on a parameter that a docstring leaves out of its Parameters section or
|
|
175
|
+
lists there without a description.
|
|
176
|
+
- Signatures in the API reference show the parameters' names and defaults, one per line
|
|
177
|
+
when long, and the types stay in the docstrings, which state the type of every value
|
|
178
|
+
that a public method or property returns. The types link to the documentation of
|
|
179
|
+
telescopic, Python, NumPy and matplotlib.
|
|
180
|
+
- American spelling throughout the package, its tests and the site, with "Atchadé" spelled
|
|
181
|
+
one way; codespell checks it in `scripts/verify.sh`, CI's lint job and a pre-commit
|
|
182
|
+
hook.
|
|
183
|
+
- The Quickstart writes the lag as $L$ in its equations, defines the pilots and a
|
|
184
|
+
consistent estimate where it first uses them, and says how to turn on the tail check.
|
|
185
|
+
- Theory opens with what it derives, writes the algorithm without the meeting time and
|
|
186
|
+
defines it after, and says what the conditions of unbiasedness ask in practice before
|
|
187
|
+
stating them.
|
|
188
|
+
- The kernels guide defines its coupling terms before its table, the result-fields
|
|
189
|
+
reference says what Hill's estimate and the Clopper-Pearson bound measure, and the
|
|
190
|
+
warnings reference when each warning is emitted; the docstring of `diagnostics.hill`
|
|
191
|
+
gives the rule for ties.
|
|
192
|
+
- The guide to choosing an initial distribution links `initial.as_initial`, which reads
|
|
193
|
+
`init`.
|
|
194
|
+
- Fixes from an audit of the whole package: a number argument of the wrong type raises
|
|
195
|
+
`TypeError`, and one out of bounds `ValueError`, naming the argument; `names` must be
|
|
196
|
+
distinct strings, one per coordinate; `Kernel.check_ndim` checks a kernel's dimension;
|
|
197
|
+
variances are computed about the atoms' mean; tuning does not depend on the
|
|
198
|
+
coordinates' scales; the engine advances up to 256 replicates at a time.
|
|
199
|
+
- Fixes from a second audit: a gradient that is not finite where the log-density is
|
|
200
|
+
finite is taken as 0 where chains move, which keeps MALA and HMC exact, and raises
|
|
201
|
+
with the point where they start, where MALA and HMC rejected such proposals and so
|
|
202
|
+
sampled a restricted target; a run that meets one warns as it does, or when it ends on
|
|
203
|
+
a pool, and `Result.n_grad_zeroed` counts them; the maximal coupling keeps each
|
|
204
|
+
chain's law at draws where a log-density is infinite, and takes SciPy's Dirichlet
|
|
205
|
+
laws; `check_coupling` swaps half the pairs, so that it catches a coupling that reads
|
|
206
|
+
another row's state, and fails a NaN p-value; `check()` and the summary report a slow
|
|
207
|
+
pair when every pair is censored; `hill` and `variance_share` check their values;
|
|
208
|
+
every bounded number argument raises "must be in (low, high)", and `dual_averaging`,
|
|
209
|
+
the TV and W1 bounds, the estimators, `SignedMeasure.mass`, `plotting.paths`,
|
|
210
|
+
`Target(vectorize=)` and `pool` check what they were missing; a first Ctrl-C after the
|
|
211
|
+
replicates, while the result is built, no longer loses the run, and a process that
|
|
212
|
+
ignores Ctrl-C, or whose handler Python did not set, keeps its handler; the tuning
|
|
213
|
+
pilot takes a third less time at d = 100, Gibbs sweeps less, and joint histograms take
|
|
214
|
+
memory in proportion to the atoms (`SignedMeasure.mass` is sparse).
|
|
215
|
+
- Changes from a statistical audit against the source papers: `Result.estimate` builds
|
|
216
|
+
its interval with the quantile of Student's t with $R - 1$ degrees of freedom instead
|
|
217
|
+
of the normal quantile, whose 95% intervals covered 0.878 at $R = 5$ on an
|
|
218
|
+
autoregressive chain, where Student's t covered 0.950; the stated
|
|
219
|
+
guarantee of unbiasedness requires that the chain converge from the initial
|
|
220
|
+
distribution; `Gibbs(coupling="crn")` uses common random numbers for pairs whose
|
|
221
|
+
distance underflows to 0, which went to the maximal coupling; and the documentation
|
|
222
|
+
corrects the meaning of the relative cost and the source of HMC's target acceptance
|
|
223
|
+
rate, and describes `discrete_maximal` as serving kernels on finite state spaces, not
|
|
224
|
+
a built-in kernel.
|
|
225
|
+
- Fixes of run-time defects: a vectorized log-density that returns shape `()` for one
|
|
226
|
+
point, as SciPy's `multivariate_normal.logpdf` does, or any output that differs from
|
|
227
|
+
the expected shape only by axes of length 1, is accepted; `Target` copies what its
|
|
228
|
+
functions return, so one that reuses its output array no longer corrupts states; an
|
|
229
|
+
`Independence` proposal whose `log_density` is NaN or `+inf` raises with the point
|
|
230
|
+
instead of biasing the chain; the meeting-time quantiles of `Result.diagnostics()` and
|
|
231
|
+
the summary cover every pair, `inf` (printed `> max_iter`) where one falls on a
|
|
232
|
+
censored pair, and are observed meeting times (the inverted empirical CDF), so they
|
|
233
|
+
change for runs without censoring too: the 90% quantile of meeting times 1 to 100 is
|
|
234
|
+
90, not 90.1, and the median of an even number of pairs is the lower middle value;
|
|
235
|
+
the summary's footer has `max_iter`; the survival curve of the meeting times ends at
|
|
236
|
+
the fraction of pairs censored; `sample()` refuses fewer than 2 replicates before
|
|
237
|
+
tuning; a `Result` with no replicates, Mixture weights whose sum overflows, a tuned
|
|
238
|
+
mixture whose components differ in dimension, a kernel that drops its states'
|
|
239
|
+
gradients, and `coupling="crn"` with conditionals whose `mean` and `cov` are methods
|
|
240
|
+
raise a `ValueError` or `TypeError` that names the cause; MALA's coupled step no
|
|
241
|
+
longer warns when its drift overflows.
|
|
242
|
+
- Input validation: an array argument that is not real numbers, such as a string (a
|
|
243
|
+
numeric one included), `None`, a boolean, a complex number or a ragged list, raises
|
|
244
|
+
`TypeError` naming the argument and the expected form, where NumPy's message named
|
|
245
|
+
neither; real numbers held as objects, such as `Fraction`, `Decimal` or an object
|
|
246
|
+
column of pandas, still convert to floats. `as_initial` raises its own `TypeError` for
|
|
247
|
+
a ragged `init`. A flag that is not `True` or `False` (`vectorize`, `progress`,
|
|
248
|
+
`strict`, `store`, `keep_paths`), and an `args` that is not a tuple or a list, raise
|
|
249
|
+
`TypeError` naming the argument, and so do a target or a kernel that is not a
|
|
250
|
+
`Target` or `Kernel` instance, such as a bare log-density passed to `engine.run` or a
|
|
251
|
+
kernel class in a `Mixture`. `SignedMeasure` checks its arrays: `atoms` and `weights`
|
|
252
|
+
that are not real numbers raise `TypeError`, and wrong shapes or a replicate index
|
|
253
|
+
that is not an integer in range raise `ValueError`. Its attributes are read-only views
|
|
254
|
+
of the arrays passed in, so they cannot be written through; the arrays passed in, such
|
|
255
|
+
as those of the `Replicates` that `engine.run` returns, stay writable: the package
|
|
256
|
+
never writes to them, and a user who does changes the measure. `unbiased_variance`
|
|
257
|
+
and `unbiased_covariance` of a scalar raise `ValueError`.
|
|
258
|
+
`CoupledSampler.meeting_times` refuses `max_iter=None`, so the pilot is always capped,
|
|
259
|
+
and `slow_pair_threshold` checks that `lag` is at least 1 and `m` at least 0.
|
|
260
|
+
- A target function's output that is not numbers, such as `None` or a string, at one
|
|
261
|
+
point among good ones raises `ValueError` naming the function and the point; an emcee
|
|
262
|
+
`(log_prob, blobs)` tuple is told that derived quantities come from `Result.estimate`.
|
|
263
|
+
A pointwise function whose outputs differ from point to point only by axes of length
|
|
264
|
+
1, such as a float at some points and SciPy's `logpdf` of shape `(1,)` at others, is
|
|
265
|
+
accepted, and one evaluated on no points returns an empty array. A complex output
|
|
266
|
+
with an imaginary part of exactly 0 is its real part, and any other complex output
|
|
267
|
+
raises; floating outputs narrower than float64, as JAX returns by default, emit one
|
|
268
|
+
`InputWarning` per target that names their dtype.
|
|
269
|
+
- When `names` and the initial distribution differ in dimension, the error names the
|
|
270
|
+
dimension the initial distribution draws; tuning chains whose covariance overflows,
|
|
271
|
+
on a target flat in some direction or with scales near the float64 limit, raise an
|
|
272
|
+
error that says so, instead of NumPy's overflow warnings and "cov must be finite".
|
|
273
|
+
- Tuning a MALA or HMC step size no longer raises when a pilot chain ends where the
|
|
274
|
+
gradient is not finite but the log-density is: its dual-averaging chains take that
|
|
275
|
+
gradient as 0, as runs do wherever chains move.
|
|
276
|
+
- The package ships a `py.typed` marker, so type checkers such as mypy and pyright read
|
|
277
|
+
its annotations, and its metadata lists the supported Python versions (3.11 to 3.15),
|
|
278
|
+
that it runs on any operating system, that it is typed, and a link to its issues.
|
|
279
|
+
- An `Independence` chain at a point where the target and the proposal both have zero
|
|
280
|
+
density, such as a start outside the support of a bounded proposal, accepts any
|
|
281
|
+
proposal of finite density, as the other Metropolis kernels do; it rejected every
|
|
282
|
+
proposal, with a NumPy `RuntimeWarning`.
|
|
283
|
+
- Fixes and checks of a hardening pass, now recorded and tested: a `Mixture` never
|
|
284
|
+
applies a component of weight 0, which the largest uniforms could select where
|
|
285
|
+
rounding left the cumulative weights below 1. `Gibbs(coupling="crn")` refuses a
|
|
286
|
+
conditional whose `mean` is not a vector of its block's size, where a scalar was
|
|
287
|
+
added to every coordinate. `weighted_quantile` refuses values or weights that are not
|
|
288
|
+
finite, `choose_k` meeting times that are not positive integers or `inf`,
|
|
289
|
+
`SignedMeasure.mass` a cell that is not an integer, which it truncated, `hill` values
|
|
290
|
+
that are not finite, and `testing.random_draws` the seeds that a run refuses;
|
|
291
|
+
`plot_marginals` and `plot_corner` check `bins` and the number of replicates before
|
|
292
|
+
opening a figure. `Result.merge` takes the kernel, initial distribution, tuning report
|
|
293
|
+
and pilot meeting times of the other result where the first has none. The warning
|
|
294
|
+
about disagreeing tuning chains also fires where an R-hat is NaN, which hid a
|
|
295
|
+
disagreement in another coordinate: it names those coordinates, which the pilot never
|
|
296
|
+
moved in, and reports the largest finite R-hat.
|
|
297
|
+
- The warning that the tuning chains disagree says that the chains may also not have
|
|
298
|
+
converged, and the documentation of `TuningReport.rhat`, `tuning_disagreement` and
|
|
299
|
+
`CoupledSampler.tune` says that chains that agree do not show that the target has one
|
|
300
|
+
mode.
|
|
301
|
+
- The documentation states that an automatically tuned `Independence` proposal covers
|
|
302
|
+
only the modes its tuning chains reached, so a run on well-separated modes can be
|
|
303
|
+
confidently wrong without a warning; the failure-modes tutorial shows such a run and
|
|
304
|
+
two checks that help.
|
|
305
|
+
- `Independence`'s `proposal` is typed as any object with `sample` and `log_density`,
|
|
306
|
+
as it already behaved, so type checkers accept a custom proposal.
|
|
307
|
+
- The documentation states that the default range of `Result.histogram` biases every
|
|
308
|
+
bin, and that `CouplingReport.passed()` fails a correct coupling with probability up
|
|
309
|
+
to about 4 `alpha`.
|
|
310
|
+
- An `Independence` proposal drawn where the proposal's own `log_density` is `-inf`,
|
|
311
|
+
such as a draw clipped onto the edge of an open support, is rejected; it was accepted
|
|
312
|
+
and its chain never left it. The documentation states that `log_density` is the
|
|
313
|
+
normalized density of what `sample` draws, positive wherever `sample` can land.
|
|
314
|
+
- The Student-$t$ log-density of `MultivariateT` is finite, without a NumPy warning, at
|
|
315
|
+
points whose squared distance from the mean overflows float64, beyond about 1.34e154
|
|
316
|
+
scale units; it was `-inf` there. This holds for scale matrices above about 1e-307 and
|
|
317
|
+
a finite offset `x - mean`: for a smaller scale matrix the value stays `-inf`, and
|
|
318
|
+
where the offset itself overflows it stays NaN, each with a NumPy warning.
|
|
319
|
+
- The documentation states that an `Independence` proposal must be positive wherever the
|
|
320
|
+
target is: used alone, the kernel never reaches the part of the target's support that
|
|
321
|
+
the proposal misses, so the estimates are biased without a warning, and a chain
|
|
322
|
+
started where the proposal is 0 and the target is not never moves.
|
|
323
|
+
- The documentation states what an `Independence` proposal with lighter tails than the
|
|
324
|
+
target does: with unbounded weights $\pi/q$, a run usually gives too little mass to
|
|
325
|
+
the region where the weights are large, with error bars that are too small and often
|
|
326
|
+
without a warning; the kernels guide has a measured example.
|
|
327
|
+
- The docstrings of `sample()` and `CoupledSampler.run` say that their estimates are
|
|
328
|
+
unbiased unless `max_iter` censors a pair, which biases them, or a Ctrl-C interrupts
|
|
329
|
+
the run, which leaves them consistent.
|
|
330
|
+
- The warnings about late pairs, a replicate dominating the variance, heavy-tailed
|
|
331
|
+
meeting times and slow pairs end with the remedy in a few words, as the warning about
|
|
332
|
+
censored pairs did. A slow pair seen as it happens says that the run waits for it,
|
|
333
|
+
and for a replicate that a first Ctrl-C lets it finish. The warning about tuning
|
|
334
|
+
chains that disagree advises an initial distribution that covers every mode only
|
|
335
|
+
unless the one given already does.
|
|
336
|
+
- `Result.diagnostics()` reports `variance_share_replicate`, the index of the replicate
|
|
337
|
+
that holds the largest share of the variance of an estimate, and the variance warning
|
|
338
|
+
names it.
|
|
339
|
+
- A replicate or pilot pair that starts where the target density is zero is reported
|
|
340
|
+
as soon as it starts, in this process, instead of when the run ends; the slow-pair
|
|
341
|
+
warning of such a pair says so, the censoring warning no longer suggests running
|
|
342
|
+
without a cap after such starts, and a pilot that cannot choose `k` names them instead
|
|
343
|
+
of advising a wider initial distribution. `engine.Status` carries the number of
|
|
344
|
+
replicates started at zero density so far, the first of them, and whether the
|
|
345
|
+
slowest pair is one of them.
|
|
346
|
+
- The memory warning compares the estimated peak of a run and its first estimates, about
|
|
347
|
+
three times the stored atoms and distances, with its threshold of 1 GB, and states both
|
|
348
|
+
figures, with twice the peak as its upper end in one or two dimensions, where few
|
|
349
|
+
repeated atoms can make the estimates take up to about five times the stored size;
|
|
350
|
+
`telescopic.engine.stored_bytes` computes the stored size, and refuses steps that are
|
|
351
|
+
not non-negative integers.
|
|
352
|
+
- `progress=True` also shows the progress of tuning: the steps of the adaptive pilot
|
|
353
|
+
chains and, for MALA and HMC, of the step size's dual averaging.
|
|
354
|
+
- Changes to `Result` ruled before the first release: the last bin of a histogram is
|
|
355
|
+
closed, as in `numpy.histogram`, so an atom on the upper edge of `range` is counted,
|
|
356
|
+
and the last edge of the default range is no longer nudged up; the TV bound and its
|
|
357
|
+
value at `k` count a censored pair as meeting at its cap plus 1, since its chains were
|
|
358
|
+
compared at the cap, which raises the bound by $1/R$ per censored pair at each
|
|
359
|
+
$t \le$ cap $- L$ where $L$ divides cap $- L - t$, and
|
|
360
|
+
`telescopic.diagnostics.tv_bound` asks for a censored pair as its cap plus 1;
|
|
361
|
+
`Result.interval` is renamed `Result.credible_interval`, with no alias, and
|
|
362
|
+
`Estimate.interval` is an array of shape `(2,)` or `(2, p)`, lower ends first,
|
|
363
|
+
instead of a tuple of two arrays;
|
|
364
|
+
`Result.quantile` and `Result.credible_interval` take a function `h`, as `estimate`
|
|
365
|
+
does, for the quantiles of a derived quantity; a `Result` prints as one line of its
|
|
366
|
+
settings, such as `Result(R=100, d=2, k=63, m=630, lag=63, censored=0,
|
|
367
|
+
interrupted=False)`.
|
|
368
|
+
- A pair censored at a `max_iter` equal to the slow-pair threshold now raises the
|
|
369
|
+
slow-pair warning, since its chains were compared, unmet, at the threshold.
|
|
370
|
+
- The summary shows as an HTML table in notebooks, its footer a list with one warning
|
|
371
|
+
per item. Its text keeps the lines below the table within 80 characters, with the
|
|
372
|
+
kernel on a line of its own and its floating-point parameters to 4 significant
|
|
373
|
+
figures, and sizes each column of the table to its entries.
|
|
374
|
+
- `plotting.paths` draws $X$ in magenta and $Y$ in teal, the documentation's chain
|
|
375
|
+
colors, and a pair in the dark ink of met chains from its meeting time on; the colors
|
|
376
|
+
are `plotting.CHAIN_X`, `CHAIN_Y` and `MET`. A legend says which line is which, and in
|
|
377
|
+
one dimension the time axis has integer ticks.
|
|
378
|
+
- The pool of worker processes that telescopic starts, with the semaphores of its stop
|
|
379
|
+
event, is freed when the caller drops an error raised in a worker. A reference cycle
|
|
380
|
+
held them until a later garbage collection, which on Python 3.11 and 3.12 can warn
|
|
381
|
+
that the resource tracker was called reentrantly and leave the semaphores to leak.
|
|
382
|
+
- Each public module of the package lists in `__all__` the names that the API reference
|
|
383
|
+
documents, so a star import from `telescopic.diagnostics`, for example, and `help()` on
|
|
384
|
+
it no longer list the helpers that the module imports.
|
|
385
|
+
- A sampler built with `grad` and a kernel that evaluates it compares `grad` with
|
|
386
|
+
central differences of `log_prob` along 8 lines through draws of the initial
|
|
387
|
+
distribution, before tuning, and emits an `InputWarning` with the size of the
|
|
388
|
+
disagreement in nats where they disagree beyond rounding, or when it could compare no
|
|
389
|
+
line. It costs 40 evaluations of `log_prob` and 8 of `grad` at any dimension for
|
|
390
|
+
float64 values, and 48 draws of the initial distribution, draws from a random stream
|
|
391
|
+
of its own and changes no result; `check_grad=False` on
|
|
392
|
+
`CoupledSampler` and `sample` turns it off, and `CoupledSampler.gradient_check`, a
|
|
393
|
+
`diagnostics.GradientCheck`, records what it compared. An error raised inside the
|
|
394
|
+
check keeps its type and message, with a note that it was raised in the check.
|
|
395
|
+
- `Gibbs(coupling="crn")` draws a block of several coordinates, or of one without `ppf`,
|
|
396
|
+
from each chain's own conditional with generators in the same state, so each chain
|
|
397
|
+
keeps its conditional's law; a pair of chains takes a common uniform or these
|
|
398
|
+
generators by its own two conditionals, so a replicate's output does not depend on the
|
|
399
|
+
other replicates in its batch. It took such a conditional to be the normal with its
|
|
400
|
+
`mean` and `cov`, which gave a conditional that is not normal the wrong law in the
|
|
401
|
+
coupled step only, and it refused conditionals without a `mean` and a `cov` that are
|
|
402
|
+
values, such as SciPy's frozen `dirichlet`, whose `mean` and `cov` are methods,
|
|
403
|
+
`wishart`, which has no `cov`, and `multivariate_t`, which has neither. Blocks of one
|
|
404
|
+
coordinate with `ppf`, and the maximal coupling, give the same numbers as before.
|
|
405
|
+
- `Draws.child(row)` returns a new child of a row's generator, which does not move the
|
|
406
|
+
row's stream: two draws from it can read the same numbers, as the Gibbs kernel's common
|
|
407
|
+
random numbers do.
|
|
408
|
+
- A request of `Draws` for no rows returns an empty array. It raised `ValueError` when it
|
|
409
|
+
asked for at least two numbers per row more than the buffer held, as for two normals
|
|
410
|
+
per row of replayed draws without normals.
|
|
411
|
+
- `import telescopic` no longer imports `scipy.stats`, `scipy.optimize` and
|
|
412
|
+
`scipy.integrate`: the functions that use them import them at their first call. That
|
|
413
|
+
shortens the import, and with it the start of each worker of a process pool; the first
|
|
414
|
+
call that needs `scipy.stats`, such as the end of the first run of `sample`, pays its
|
|
415
|
+
import once.
|
|
416
|
+
- `Result.cov` weights the atoms in blocks of 1 MiB, so its peak memory is about the
|
|
417
|
+
atoms' size plus a block rather than twice the atoms; `cov` can differ from before in
|
|
418
|
+
the last bits.
|
|
419
|
+
- `Result.quantile` gathers one coordinate at a time instead of copying the atoms, which
|
|
420
|
+
lowers its peak memory.
|
|
421
|
+
- `Result.var`, `Result.std` and the diagnostics share each replicate's moments,
|
|
422
|
+
computed once, so `summary()` centers the atoms once; `var` and `std` can differ from
|
|
423
|
+
before in the last bits.
|
|
424
|
+
- `SignedMeasure` requires `replicate` in nondecreasing order, each replicate's atoms
|
|
425
|
+
consecutive, and raises `ValueError` otherwise; its sums share the weights and hold
|
|
426
|
+
8 bytes per atom fewer.
|
|
427
|
+
- With a vectorized target (`vectorize=True`), RandomWalk, MALA, HMC and the tuning
|
|
428
|
+
pilot compute their products of a batch of chains with a matrix by BLAS: whole runs of
|
|
429
|
+
256 replicates on a Gaussian of 200 dimensions took 2.1 times less processor time with
|
|
430
|
+
RandomWalk, whose pairs all ran to the iteration cap, and 3.4 times less with MALA.
|
|
431
|
+
Such a run repeats bitwise only with the same seed and settings, `pool` and
|
|
432
|
+
`n_workers`, BLAS build and number of BLAS threads; runs of other lane counts, pools,
|
|
433
|
+
merges and later calls of a sampler, and runs on workers, which use one BLAS thread,
|
|
434
|
+
against runs in a process with more, can differ by rounding, which can move a
|
|
435
|
+
replicate's meeting time and its whole output, while the estimates agree within their
|
|
436
|
+
error bars. Seeded outputs of vectorized runs change likewise. A target evaluated
|
|
437
|
+
point by point keeps every bitwise guarantee. `couplings.reflection_maximal` takes
|
|
438
|
+
`blas=True` to do the same.
|
|
439
|
+
- The guide "Check and set a step size" names a resonance of HMC's leapfrog on
|
|
440
|
+
Gaussians, on which a given `n_steps`, or a given `cov` that does not whiten the
|
|
441
|
+
target, can put the automatic step. With MALA or HMC, the error raised when `k` cannot
|
|
442
|
+
be chosen carries a note that points to it.
|
|
443
|
+
- The documentation's pages are split by task. Start holds Install, the Quickstart and
|
|
444
|
+
Coming from emcee; Unbiased on average is the second tutorial; the how-to guides write
|
|
445
|
+
the log-density, choose an initial distribution, a kernel and a step size, set the run's
|
|
446
|
+
arguments, estimate, plot, save, load and merge, read meeting times, run in parallel and
|
|
447
|
+
write a kernel; Reference adds the fields of a result and the warnings. The addresses
|
|
448
|
+
`getting-started`, `tutorials/beside-emcee`, `guide/targets`, `guide/results` and
|
|
449
|
+
`guide/diagnostics` are gone.
|
|
450
|
+
- `couplings.reflection_maximal`, which the coupled steps of RandomWalk, MALA and HMC
|
|
451
|
+
call, reflects with one product with the covariance factor instead of two: a call at
|
|
452
|
+
256 rows took 1.08 to 1.38 times less time at d = 2 to 200. Seeded outputs of their
|
|
453
|
+
coupled runs change: in the last bits for RandomWalk and MALA used alone; for kernels
|
|
454
|
+
whose chains come close without meeting, such as HMC or a `Mixture` with a contracting
|
|
455
|
+
component, a meeting time can move, and with it a replicate's estimates (one of 100 on
|
|
456
|
+
a logistic regression of 6 dimensions with HMC, which moved the estimates by up to
|
|
457
|
+
0.075 standard errors).
|
|
458
|
+
- `MALA` computes its step and coupled step in whitened coordinates: 3 products of a
|
|
459
|
+
row with a $d \times d$ factor per step and 7 per coupled step, against 7 and 14. A
|
|
460
|
+
single step took 0.66 to 0.76 times the time at d = 100 and 200, and a coupled step
|
|
461
|
+
0.80 to 0.82 times at d = 100 (medians of four benchmark runs on a dense vectorized
|
|
462
|
+
target, with the form as prototyped). It is the same kernel; seeded outputs of runs
|
|
463
|
+
that step MALA change in the last bits.
|
|
464
|
+
- The tuning pilot draws its normals and uniforms 256 steps at a time instead of at
|
|
465
|
+
every step, which made it 1.24 to 1.32 times faster on a Gaussian target at d = 2 to
|
|
466
|
+
100. Its outputs are unchanged.
|
|
467
|
+
- `Independence` computes its weights with fewer operations per step, and a Student-t
|
|
468
|
+
`MultivariateT` its normalizing constant once: a one-lane run with a Student-t
|
|
469
|
+
proposal at d = 20 took 1.12 times less time. Its outputs are unchanged.
|
|
470
|
+
- A request for random numbers takes less time: on a nearly free target at d = 2, the
|
|
471
|
+
time in requests per step of dual averaging (4 chains), or of the engine or a kernel
|
|
472
|
+
at one lane, fell by 5 to 17 µs, about a third, in every run. The median time of a
|
|
473
|
+
whole step was 0.89 to 0.95 times as long, but single runs ranged from 0.79 to 1.35
|
|
474
|
+
times; at 256 lanes no change was measured. Outputs are unchanged.
|
|
475
|
+
- `CoupledSampler.resume(result)` continues a returned, loaded or merged result on a new
|
|
476
|
+
sampler: it adopts the result's seed, replicates, settings, pilot and tuning, and the
|
|
477
|
+
next `run` completes the replicates an interrupted run never started, then continues
|
|
478
|
+
above the highest index requested. It checks the dimension, the kernel's class, an
|
|
479
|
+
`rng` given to the constructor and the names; the target and the kernel's parameters
|
|
480
|
+
are the caller's to match. An untuned kernel, as a loaded result needs, is tuned again
|
|
481
|
+
from the result's seed; an `InputWarning` says when the kernel's tuning or description
|
|
482
|
+
differs from the result's.
|
|
483
|
+
- Proposal and coupling objects: `kernels.MetropolisHastings(proposal, coupling)` with
|
|
484
|
+
the proposals `RandomWalkProposal`, `LangevinProposal` and `IndependenceProposal`, and
|
|
485
|
+
the couplings `couplings.Reflection`, `couplings.Maximal` and `couplings.Shared`, each
|
|
486
|
+
of which supports only the proposals it was published for. `RandomWalk`, `MALA` and
|
|
487
|
+
`Independence` are built on them, and their seeded outputs are unchanged bit for bit.
|
|
488
|
+
`RandomWalk(coupling=...)` also takes `Reflection()` or `Maximal()`;
|
|
489
|
+
`RandomWalk.coupling` and `Independence.proposal` can no longer be reassigned.
|
|
490
|
+
- An error during the replicates, such as one of the log-density, no longer loses the
|
|
491
|
+
replicates finished before it. The same exception is raised again with one note:
|
|
492
|
+
`engine.run` attaches the finished replicates as `telescopic_replicates`, and
|
|
493
|
+
`CoupledSampler.run` and `sample` keep them and attach the result of all the sampler's
|
|
494
|
+
replicates as `telescopic_result`, whose next `run`, or `resume`, starts with the
|
|
495
|
+
missing ones. The replicates in progress at the error are listed in
|
|
496
|
+
`Replicates.abandoned` and `Result.abandoned`, saved, and named in the summary until
|
|
497
|
+
they run. On a pool the error stops the run as a first Ctrl-C does; an error that does
|
|
498
|
+
not unpickle becomes a `RuntimeError` with the worker's traceback in a note, instead of
|
|
499
|
+
breaking a process pool.
|
|
500
|
+
- Each atom records the time at which it was recorded, `Replicates.time` (int32), and
|
|
501
|
+
`Result.chains()` returns the averaged states of each kept replicate as chains of equal
|
|
502
|
+
length. `max_iter` must be at most 2**31 - 1 where times are stored, and a stored atom
|
|
503
|
+
costs 8d + 20 bytes instead of 8d + 16.
|
|
504
|
+
- `Result.to_datatree()` returns the chains of `Result.chains()` as ArviZ data, one
|
|
505
|
+
variable per parameter name with the replicate indices and times as coordinates, as an
|
|
506
|
+
`xarray.DataTree`; it needs ArviZ 1.0 or newer, which needs Python 3.12 and NumPy 2,
|
|
507
|
+
through the new extra `telescopic[arviz]`.
|
|
508
|
+
- `keep` on `CoupledSampler.run`, `sample` and `engine.run` (and `engine.Settings.keep`)
|
|
509
|
+
stores the signed measures and distances of the replicates of index below `keep` only,
|
|
510
|
+
and the moments of every replicate (`Replicates.center` and `Replicates.moments`), from
|
|
511
|
+
which `mean`, `var`, `std` and `cov` (up to 100 dimensions) come; `estimate`, the
|
|
512
|
+
quantiles, the histograms and their plots come from the `n_kept` kept replicates
|
|
513
|
+
(`Result.keep`, `Result.n_kept`), and the summary and the repr name the replicates
|
|
514
|
+
behind each figure. The memory warning counts the moments.
|
|
515
|
+
- The variance share of the diagnostics takes each replicate's second moments about the
|
|
516
|
+
mean estimate instead of the atoms' mean, which changes its values.
|
|
517
|
+
- Results are saved in schema 2, which names the estimator family and keeps `keep`, the
|
|
518
|
+
times, the moments and the abandoned replicates; files of schema 1 load with their
|
|
519
|
+
times rebuilt.
|
|
520
|
+
- `HMC` jitters its step by default: each trajectory takes a step drawn uniformly
|
|
521
|
+
between `(1 - jitter)` and `(1 + jitter)` times `step_size`, the same for both chains
|
|
522
|
+
of a pair, with `n_steps` fixed by `step_size`, and the automatic step is tuned on the
|
|
523
|
+
jittered kernel. The new argument `jitter`, in [0, 1), is 0.5 by default and shown in
|
|
524
|
+
the repr; `jitter=0` gives the fixed-step kernel, bit for bit. The jitter keeps the
|
|
525
|
+
step off the leapfrog's resonance: on the Gaussians where a given `n_steps`, or a
|
|
526
|
+
given `cov` that does not whiten the target, left pilot pairs unmet, `k` is chosen. Every seeded output of
|
|
527
|
+
`HMC` with the default changes, and the note on the error raised when `k` cannot be
|
|
528
|
+
chosen now suggests the default jitter for HMC with `jitter=0`.
|
|
529
|
+
- `State` has a fourth field, `extra`: arrays of one kernel, batch first, such as a
|
|
530
|
+
momentum or a cache. A kernel names its Markov fields in `Kernel.markov_fields` and
|
|
531
|
+
gives their initial values in `Kernel.init_extra`, which `init_state` attaches and
|
|
532
|
+
checks for every Markov field; a pair
|
|
533
|
+
meets when its positions and Markov fields are equal. Kernels, `State.take`,
|
|
534
|
+
`State.put` and `Mixture` carry unchanged the fields they do not know, a `Mixture`
|
|
535
|
+
names component `i`'s fields `"i/<name>"` and refuses components with Markov fields,
|
|
536
|
+
and `check_coupling` counts meetings on the Markov state and counts as stale the chains
|
|
537
|
+
whose caches change their next step. No shipped kernel has such fields, and every
|
|
538
|
+
seeded output is unchanged. Code that unpacks `dataclasses.astuple(state)` into three
|
|
539
|
+
names breaks.
|
|
540
|
+
- `Independence` keeps log q at each chain's position in the chain's state, with the point
|
|
541
|
+
at which it was computed, and uses it only where that point is the position bit for
|
|
542
|
+
bit: a step and a coupled step evaluate the proposal's `log_density` at the proposals
|
|
543
|
+
and at the states without a valid value, usually n rows where they were 2n and 3n, and
|
|
544
|
+
with `MultivariateT` every seeded output is unchanged. `Proposal.init_extra` gives a
|
|
545
|
+
proposal's own fields.
|
|
546
|
+
- A `wide` warning when the tuning pilot shows an initial distribution more than 30
|
|
547
|
+
times wider than the target, emitted when tuning runs and listed by `check` unless
|
|
548
|
+
the run's `k` exceeds the pilot rule's:
|
|
549
|
+
`TuningReport.initial_width` and `PilotRun.initial_width` hold the geometric mean over
|
|
550
|
+
coordinates of the ratio of the standard deviations of the initial draws to the
|
|
551
|
+
pilot's, `PilotRun.initial_var` the draws' variances, and `diagnostics.wide_start`
|
|
552
|
+
words the warning. The guide on settings shows a confirmation round of pilot pairs at
|
|
553
|
+
lag `k` as an option.
|
|
554
|
+
- `plotting.survival(meeting_times, lag, ax=None, *, max_iter=None, label=None)` draws
|
|
555
|
+
the survival function of an array of meeting times, such as
|
|
556
|
+
`CoupledSampler.meeting_times` returns, into a given axis, so that several runs share
|
|
557
|
+
one; a censored pair (`inf`) counts up to `max_iter`, as in
|
|
558
|
+
`plotting.meeting_times`, which now draws its curve with it.
|
|
559
|
+
- `Result.merge` takes any number of results, `a.merge(b, c, d)`, and joins them in one
|
|
560
|
+
pass.
|
|
561
|
+
- `CoupledSampler.run(n, start=i)` runs the replicates of indices `i` to `i + n - 1`, so
|
|
562
|
+
that separate samplers with one seed and the same settings run the ranges of one run.
|
|
563
|
+
- Checkpoints: `sample(..., checkpoint=directory)` and
|
|
564
|
+
`CoupledSampler.run(..., checkpoint=directory)` write the run's plan (seed, settings,
|
|
565
|
+
tuning report, pilot and the version of telescopic) and then its replicates as they
|
|
566
|
+
finish, every 256 in this process and each chunk on a pool, each file renamed into
|
|
567
|
+
place once whole. The same call, with the same `rng`, adopts the directory's plan,
|
|
568
|
+
reads the replicates of its call stored there and runs the others, so it completes a
|
|
569
|
+
run whose process was killed. `CoupledSampler.plan(n, ...)` fixes the settings without
|
|
570
|
+
running replicates and writes them as a plan of `n` replicates, for the tasks of a
|
|
571
|
+
cluster job, which run their ranges with `start`, also on `sample`;
|
|
572
|
+
`Result.load(directory)` merges every replicate a checkpoint holds, and warns when
|
|
573
|
+
tasks tuned their kernel differently from the plan, as on another type of CPU.
|
|
574
|
+
|
|
575
|
+
### Changed
|
|
576
|
+
|
|
577
|
+
- `diagnostics.tv_bound`, `diagnostics.w1_bound`, `Result.tv_bound` and
|
|
578
|
+
`Result.w1_bound` return the pair `(bound, standard_error)`, the standard error being
|
|
579
|
+
that of the average over replicates of each pair's term; the bounds are unchanged, bit
|
|
580
|
+
for bit. `diagnostics.w1_bound` takes `distance_owner` first, as
|
|
581
|
+
`engine.Replicates` holds it, since the error needs each record's replicate.
|
|
582
|
+
`plot_tv_bound` draws a band of two standard errors. Code that used the single array,
|
|
583
|
+
or the former arguments of `diagnostics.w1_bound`, breaks.
|