binference 0.1.0__tar.gz → 0.2.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.
Files changed (97) hide show
  1. binference-0.2.0/CHANGELOG.md +605 -0
  2. {binference-0.1.0 → binference-0.2.0}/CITATION.cff +2 -2
  3. {binference-0.1.0 → binference-0.2.0}/LICENSE +1 -1
  4. {binference-0.1.0 → binference-0.2.0}/PKG-INFO +3 -1
  5. {binference-0.1.0 → binference-0.2.0}/pyproject.toml +2 -2
  6. {binference-0.1.0 → binference-0.2.0}/src/binference/__init__.py +7 -12
  7. {binference-0.1.0 → binference-0.2.0}/src/binference/_kernels.py +11 -24
  8. binference-0.2.0/src/binference/_quadrature.py +368 -0
  9. {binference-0.1.0 → binference-0.2.0}/src/binference/_simplex.py +5 -7
  10. {binference-0.1.0 → binference-0.2.0}/src/binference/_utils.py +60 -17
  11. binference-0.2.0/src/binference/_version.py +1 -0
  12. {binference-0.1.0 → binference-0.2.0}/src/binference/basis.py +44 -32
  13. {binference-0.1.0 → binference-0.2.0}/src/binference/bins.py +34 -33
  14. {binference-0.1.0 → binference-0.2.0}/src/binference/density.py +107 -21
  15. {binference-0.1.0 → binference-0.2.0}/src/binference/diagnostics.py +22 -48
  16. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/_curvature.py +4 -4
  17. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/_nuts_core.py +6 -1
  18. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/base.py +79 -13
  19. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/bootstrap.py +10 -11
  20. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/gibbs.py +29 -48
  21. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/laplace.py +27 -20
  22. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/nuts.py +85 -90
  23. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/optimize.py +28 -29
  24. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/vb.py +6 -8
  25. {binference-0.1.0 → binference-0.2.0}/src/binference/inference.py +155 -79
  26. {binference-0.1.0 → binference-0.2.0}/src/binference/io.py +7 -12
  27. {binference-0.1.0 → binference-0.2.0}/src/binference/likelihoods.py +177 -124
  28. {binference-0.1.0 → binference-0.2.0}/src/binference/measure.py +4 -3
  29. {binference-0.1.0 → binference-0.2.0}/src/binference/model.py +136 -84
  30. {binference-0.1.0 → binference-0.2.0}/src/binference/plotting.py +99 -59
  31. {binference-0.1.0 → binference-0.2.0}/src/binference/priors/base.py +140 -34
  32. {binference-0.1.0 → binference-0.2.0}/src/binference/priors/dirichlet.py +374 -120
  33. {binference-0.1.0 → binference-0.2.0}/src/binference/priors/hyper.py +10 -7
  34. {binference-0.1.0 → binference-0.2.0}/src/binference/priors/logistic.py +64 -59
  35. {binference-0.1.0 → binference-0.2.0}/src/binference/priors/rates.py +0 -6
  36. {binference-0.1.0 → binference-0.2.0}/src/binference/response.py +70 -44
  37. {binference-0.1.0 → binference-0.2.0}/src/binference/results.py +366 -226
  38. {binference-0.1.0 → binference-0.2.0}/src/binference/selection.py +87 -69
  39. {binference-0.1.0 → binference-0.2.0}/src/binference/simulate.py +47 -42
  40. {binference-0.1.0 → binference-0.2.0}/src/binference/validation.py +72 -23
  41. binference-0.2.0/tests/conftest.py +118 -0
  42. {binference-0.1.0 → binference-0.2.0}/tests/test_api.py +51 -2
  43. {binference-0.1.0 → binference-0.2.0}/tests/test_api_docs.py +33 -2
  44. {binference-0.1.0 → binference-0.2.0}/tests/test_auto.py +131 -9
  45. {binference-0.1.0 → binference-0.2.0}/tests/test_basis.py +244 -2
  46. {binference-0.1.0 → binference-0.2.0}/tests/test_best_loo.py +1 -1
  47. {binference-0.1.0 → binference-0.2.0}/tests/test_binning_bias.py +1 -1
  48. {binference-0.1.0 → binference-0.2.0}/tests/test_bins.py +21 -0
  49. {binference-0.1.0 → binference-0.2.0}/tests/test_constructors.py +64 -0
  50. {binference-0.1.0 → binference-0.2.0}/tests/test_density.py +78 -0
  51. {binference-0.1.0 → binference-0.2.0}/tests/test_derived_rates.py +3 -3
  52. {binference-0.1.0 → binference-0.2.0}/tests/test_diagnostics.py +17 -0
  53. {binference-0.1.0 → binference-0.2.0}/tests/test_engines.py +190 -116
  54. {binference-0.1.0 → binference-0.2.0}/tests/test_explainers.py +3 -1
  55. {binference-0.1.0 → binference-0.2.0}/tests/test_gibbs_fixes.py +8 -2
  56. {binference-0.1.0 → binference-0.2.0}/tests/test_injections.py +32 -25
  57. {binference-0.1.0 → binference-0.2.0}/tests/test_joint_response.py +9 -17
  58. {binference-0.1.0 → binference-0.2.0}/tests/test_likelihoods.py +49 -0
  59. {binference-0.1.0 → binference-0.2.0}/tests/test_map_fixes.py +12 -2
  60. {binference-0.1.0 → binference-0.2.0}/tests/test_matrix_regression.py +12 -26
  61. {binference-0.1.0 → binference-0.2.0}/tests/test_measures_masks.py +16 -1
  62. {binference-0.1.0 → binference-0.2.0}/tests/test_model.py +62 -1
  63. {binference-0.1.0 → binference-0.2.0}/tests/test_model_fixes.py +59 -27
  64. {binference-0.1.0 → binference-0.2.0}/tests/test_nuts_fixes.py +66 -10
  65. {binference-0.1.0 → binference-0.2.0}/tests/test_plotting_io.py +76 -0
  66. {binference-0.1.0 → binference-0.2.0}/tests/test_prior_fixes.py +48 -10
  67. {binference-0.1.0 → binference-0.2.0}/tests/test_priors.py +167 -30
  68. binference-0.2.0/tests/test_quadrature_peaks.py +151 -0
  69. {binference-0.1.0 → binference-0.2.0}/tests/test_response.py +33 -1
  70. {binference-0.1.0 → binference-0.2.0}/tests/test_results.py +45 -4
  71. {binference-0.1.0 → binference-0.2.0}/tests/test_results_audit.py +131 -17
  72. {binference-0.1.0 → binference-0.2.0}/tests/test_results_outputs.py +30 -1
  73. {binference-0.1.0 → binference-0.2.0}/tests/test_review_regressions.py +33 -6
  74. {binference-0.1.0 → binference-0.2.0}/tests/test_samples.py +6 -0
  75. {binference-0.1.0 → binference-0.2.0}/tests/test_sbc_cases.py +65 -4
  76. {binference-0.1.0 → binference-0.2.0}/tests/test_selection.py +14 -1
  77. {binference-0.1.0 → binference-0.2.0}/tests/test_simulate_validation.py +94 -2
  78. {binference-0.1.0 → binference-0.2.0}/tests/test_slow.py +42 -48
  79. {binference-0.1.0 → binference-0.2.0}/tests/test_values.py +2 -2
  80. binference-0.1.0/CHANGELOG.md +0 -342
  81. binference-0.1.0/notes/review/README.md +0 -39
  82. binference-0.1.0/notes/review/audit/README.md +0 -38
  83. binference-0.1.0/src/binference/_quadrature.py +0 -202
  84. binference-0.1.0/src/binference/_version.py +0 -1
  85. binference-0.1.0/tests/conftest.py +0 -84
  86. {binference-0.1.0 → binference-0.2.0}/.gitignore +0 -0
  87. {binference-0.1.0 → binference-0.2.0}/README.md +0 -0
  88. {binference-0.1.0/src/binference/samplers → binference-0.2.0/src/binference/engines}/__init__.py +0 -0
  89. {binference-0.1.0 → binference-0.2.0}/src/binference/estimator.py +0 -0
  90. {binference-0.1.0 → binference-0.2.0}/src/binference/priors/__init__.py +0 -0
  91. {binference-0.1.0 → binference-0.2.0}/src/binference/warnings.py +0 -0
  92. {binference-0.1.0 → binference-0.2.0}/tests/__init__.py +0 -0
  93. {binference-0.1.0 → binference-0.2.0}/tests/data/matrix_reference.json +0 -0
  94. {binference-0.1.0 → binference-0.2.0}/tests/test_benchmark_matrix.py +0 -0
  95. {binference-0.1.0 → binference-0.2.0}/tests/test_correlated.py +0 -0
  96. {binference-0.1.0 → binference-0.2.0}/tests/test_hygiene.py +0 -0
  97. {binference-0.1.0 → binference-0.2.0}/tests/test_simplex.py +0 -0
@@ -0,0 +1,605 @@
1
+ # Changelog
2
+
3
+ All notable changes to binference are recorded here. The format follows
4
+ [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
5
+ [Semantic Versioning](https://semver.org/) (with the usual 0.x caveat that minor
6
+ releases may break the API).
7
+
8
+ ## [0.2.0] - 2026-11-07
9
+
10
+ ### Added
11
+
12
+ - `PopulationResult.selection_draws()` and `response_draws()` return the posterior draws of
13
+ a jointly inferred selection, `(n_draws, K)`, or tallied response, `(n_draws, J, K)`.
14
+ - `infer(method=)` also takes an `Engine` subclass, so a user-written engine runs through
15
+ `infer` with the same `rng`, `progress` and options as a named one.
16
+ - The Release workflow also creates the GitHub release, with the version's CHANGELOG
17
+ section as notes and the wheel and sdist attached.
18
+ - `describe(bins, counts=None)` on `Dirichlet` and the tree priors draws the tree as
19
+ text: each branch's concentration, mean share and mean mass, or the posterior given
20
+ counts.
21
+ - `DirichletTree` takes named groups (nested dicts, with bin labels on categorical bins),
22
+ and `alpha` as a dict from group names, and bins as the tree writes them, to the
23
+ concentration of the branch into each.
24
+ - `BoundPrior.long_log_tails()`: whether a bin without data has a long tail in the
25
+ unconstrained coordinates NUTS samples.
26
+ - `Selection.from_function` and `Selection.combined` take `max_depth`, the most
27
+ refinements of their adaptive quadrature; the default, 20, allows the halvings a jump
28
+ inside a bin needs.
29
+ - `Likelihoods.from_density`, `Density.from_function` and `Density.coerce` take
30
+ `bounded=`: the bin averages of a bounded density, such as a box, and of
31
+ `from_density`'s interim prior given as a function, are checked for jumps near bin
32
+ edges as a selection function's are, at 13/8 the points per cell in 1-D.
33
+ - `Density` compares by value and is hashable: flat densities by coordinate, arrays by
34
+ their values and reading, frozen SciPy distributions by family and parameters,
35
+ functions by identity.
36
+
37
+ ### Changed
38
+
39
+ - When `check()` reports a low E-BFMI for `LogisticGP` on a grid, its hint suggests
40
+ `n_basis=10`.
41
+ - **Breaking:** `Likelihoods.basis` and the `basis` of a result are never `None`. Plain bins
42
+ are the identity basis `Basis(bins)` (order 0, resolution 1), which categories now also
43
+ take, so test `basis.is_identity` where `basis is None` was tested. An explicit
44
+ `Basis(bins)` now behaves as its plain bins, except that `Selection.from_injections`
45
+ still refuses any `Basis`. Saved files keep their layout and files from 0.1.0 still load:
46
+ a file without basis metadata is on the identity basis.
47
+ - `infer` checks the inputs of every fit, not only NUTS and Gibbs: the Monte Carlo noise
48
+ of sample likelihoods for every engine and, where the result has draws, binned counts
49
+ the response does not describe. `PointEstimate.check` includes the noise check.
50
+ - A raw array whose rows all sum to 1 raises an `InputWarning`, since it may hold
51
+ posteriors, which an array is not read as.
52
+ - **Breaking:** an explicit `n_samples` under `method="auto"` is a minimum. A Gibbs run may
53
+ be extended past it until it mixes, and Gibbs is left out when it would need more than
54
+ `max_gibbs_draws`; before, `n_samples` fixed the length and kept Gibbs at any projected
55
+ length, so passing it for speed gave a fit that did not mix.
56
+ - `Auto` takes its extension and probe settings as arguments, `extend_target`,
57
+ `extend_max_factor`, `extend_min_factor`, `probe_proposals`, `probe_draws` and
58
+ `probe_ess_share`, at the values of the constants they replace.
59
+ - **Breaking:** `GeneralizedDirichlet` on a grid of two or more dimensions needs `order`.
60
+ Its stick used to break in row-major order, which depends on how the grid is flattened.
61
+ - **Breaking:** `SBCResult.passed` requires both the chi-square and the ECDF test by
62
+ default (`method="both"`), each at `alpha / (2 n_quantities)`. Pass
63
+ `method="chisquare"` for the old behaviour.
64
+ - A tree prior stores a thin branch membership as a sparse matrix: an EM step with a
65
+ `PolyaTree` on 1024 bins takes half the time, and small trees are unchanged.
66
+ - **Breaking:** `binference.samplers` is renamed `binference.engines`, since it also holds
67
+ MAP and VB, which do not sample. There is no alias, so `from binference.samplers import
68
+ NUTS` becomes `from binference.engines import NUTS`; the API pages' URLs change with it.
69
+ - The `test` extra installs scikit-learn 1.6 or later, so the test of
70
+ `PopulationEstimator` with scikit-learn's model selection runs.
71
+ - `Selection.at_mean()` is renamed `Selection.fixed()`, the name the same operation has
72
+ on `Response`.
73
+ - A selection function's bin averages are also checked against Lobatto's 5-point rule
74
+ read just inside each cell's ends, so a jump near a cell's edge is refined to `tol`
75
+ instead of being missed without a warning.
76
+ - `Likelihoods.from_samples` refuses NaN and infinite samples, which counted as samples
77
+ outside the bins.
78
+ - `Likelihoods.from_density` evaluates frozen SciPy distributions of one family in one
79
+ call, for their exact bin masses and for their densities; the densities' check for one
80
+ family never matched, so each distribution was evaluated separately.
81
+ - `plot(stack=...)` takes the stack as `Likelihoods.stack` returns it, and on a fit with a
82
+ `Basis` shares its component weights among the bins, so `result.plot(stack=lk.stack())`
83
+ works on every fit; it failed with more components than bins and, with as many, drew
84
+ the component weights as bin fractions. A stack mapped to the bins first, as
85
+ `Likelihoods.stack`'s docstring advised, is now refused when the numbers of components
86
+ and bins differ and mapped twice when they agree. A `truth` or `stack` of the wrong
87
+ length is refused by name.
88
+ - `PopulationResult` and `PointEstimate` keep read-only copies of every array they are
89
+ given (draws, total, `value`, `x`, labels, and the arrays in `info`), freeze what they
90
+ cache, and stay read-only through pickling: writing into `samples`, `chains`,
91
+ `component_draws`, `total`, `selected`, `data_support` or a column of `summary()`
92
+ raises, `diagnostics` is a read-only mapping, and changing the array passed in no
93
+ longer changes the result.
94
+ - `check()` flags Markov chains that give no R-hat or ESS, shorter than 8 draws
95
+ (`MIXING_MIN_DRAWS`) or constant; they passed with no message.
96
+ - `PointEstimate` refuses rates with the same message as `PopulationResult`.
97
+ - `Measure` objects are immutable, as `Bins` are; renaming the shared `Measure.log()`
98
+ broke the saving of bins. `Bins`, `Selection`, `Response` and `Measure` also refuse
99
+ `del` of an attribute, after which it could be set again.
100
+ - `PopulationModel.log_likelihood` refuses a value that is not finite and non-negative,
101
+ or is all zero; a negative fraction gave a finite log-likelihood.
102
+ - `sbc` ranks the log-likelihood of a model that infers its selection or response in one
103
+ pass over the draws: the same values, about 11 times faster.
104
+ - `method="auto"` records first in `info["auto_reason"]` why a rule left Gibbs out, and
105
+ keeps an extended Gibbs result rather than rebuilding it.
106
+ - `binference.io` and `binference.plotting` are imported with the package and listed by
107
+ `dir()`; they stay out of `__all__`.
108
+ - The partial-centring weights of the logistic priors' bound form are named `gamma` (was
109
+ `lam`), also in `with_centering` and `recentre`; `info["centring"]` is unchanged.
110
+ - Tree priors take their EM weights from the concentrations, and binding no longer
111
+ builds a slot-by-node matrix: a `PolyaTree` on 2048 bins binds in 0.06 s (was 0.64 s)
112
+ (#166).
113
+ - `BoundPrior` documents the interface a new prior implements.
114
+ - `method="auto"` builds every engine it may run when it is made, so a bad engine
115
+ option, or options that no engine takes, raise before any fit (#174).
116
+ - Breaking: `init` is fractions or rates of shape (K,) for `method="auto"` and `NUTS`, as
117
+ for Gibbs and MAP; NUTS converts it with `PopulationModel.from_value` to one point that
118
+ each chain jitters. Starts in NUTS's unconstrained coordinates, shape (dim,) or
119
+ (n_chains, dim), are passed as `init_x`. Before, `NUTS(init=)` read a point in its
120
+ unconstrained coordinates, and auto refused a fraction for NUTS's start and read a rate
121
+ as a log-rate. Such a point passed as `init` is now refused by its shape, or, when it
122
+ is positive and of length K (log-rates above 0, or a logistic prior whose dimension is
123
+ K), read as fractions or rates without an error (#174, #190).
124
+ - A jittered NUTS start from `init` or `init_x` with zero density is drawn again at a
125
+ tenth of the jitter, then taken without jitter, as the start from the mode already was.
126
+ - Above 200 dimensions, NUTS takes a logistic prior's hyperparameter curvature at one
127
+ chain, like the rest of its warm-up curvature.
128
+ - The defaults page lists NUTS's divergence threshold, `_MAX_ENERGY_ERROR`.
129
+
130
+ ### Removed
131
+
132
+ - `PopulationModel.prior_transform`, `BoundPrior.prior_transform` (on the Dirichlet, tree
133
+ and `GammaRates` priors) and `BoundPrior.has_prior_transform`: the unit-cube map for
134
+ nested samplers, which nothing in binference used.
135
+ - `Engine.name` and `Engine.approximate`, which nothing read.
136
+ - `Response.measured_fractions`, which only a test used and which ignored the posterior
137
+ means of a tallied response.
138
+ - `binference.diagnostics.kkt_gap` and `binference.diagnostics.missing_information`: use
139
+ `PopulationModel.kkt_gap` and `PopulationModel.missing_information`, or
140
+ `PointEstimate.kkt_gap`.
141
+ - `simulate.Truth.extra`, which nothing set or read.
142
+ - `Bins.widths`, which nothing used; per-axis widths are `np.diff(bins.edges[d])`.
143
+ - `Dirichlet("reference")` and the `K` argument of `Dirichlet.reference()`, which takes `K`
144
+ from the bins.
145
+ - `PopulationPrior.kind` and `GammaRates.kind`; the bound prior's `kind` remains.
146
+ - The lazy `binference.__getattr__`.
147
+
148
+ ### Fixed
149
+
150
+ - Adaptive bin averages no longer lose a narrow feature that a coarse cell read. On one bin
151
+ a Gaussian with σ = 1e-3 centred on the split point read as nothing, with no warning,
152
+ and half of one above a flat background read 0.5 against 1. A point value that a cell
153
+ reads and its children do not is now followed until a cell confirms it or `max_depth`
154
+ warns. Errors are measured against the row's current estimate rather than the largest
155
+ value ever read, so an overshooting first reading no longer loosens `tol` (σ = 1e-2
156
+ read 1.032). This affects `from_density`, `Density.masses`, selection functions and
157
+ 2-D likelihoods, and a box narrow compared with its bin can now warn at the default
158
+ `max_depth`, since its error is judged against its own bin's average.
159
+ - NUTS's starting metric gives flat or negatively curved directions the largest variance
160
+ seen, as documented, rather than 1e6 times the smallest. On `LogisticGP()` with 4 bins
161
+ and 10 objects, 20 fits took 16.6 s in all against 114.1 s, with none over 5 s.
162
+ - `missing_information(include_prior=True)` includes a tree prior's curvature, so MAP's EM
163
+ message states the right rate for `GeneralizedDirichlet` and the Dirichlet trees.
164
+ - Docstrings, error messages, attribute comments on the API pages and this changelog no
165
+ longer cite design records, which the site does not include.
166
+ - The NUTS tree-depth hint of `check()` names long log tails only for priors that have
167
+ them where NUTS samples, such as a tree with a branch concentration below one; it no
168
+ longer blames trees whose concentrations are all at least one, such as
169
+ `GeneralizedDirichlet(1, 1)` or the default `PolyaTree()` on 4 bins, and suggests
170
+ `method="gibbs"` only when Gibbs can fit the model.
171
+ - A tree prior with a branch whose exponent on the simplex is exactly zero no longer
172
+ counts as unbounded through rounding, so MAP keeps it on the simplex.
173
+ - The sdist no longer includes walkthrough notes, and its tests skip the checks that
174
+ need `docs/` or `benchmarks/`, which it does not ship.
175
+ - `plot_individual` on a fit with a `Basis` drew the object's likelihood over the
176
+ components as if they were bins, or failed when there were more components than bins;
177
+ it is now shared among the bins as the hierarchical posterior is.
178
+ - The stack overlay of `plot(which="selected")` is no longer reweighted by the selection:
179
+ an average over the observed objects, it already estimates the selected population.
180
+ - `plot_sbc` always shows the joint log-likelihood; with 12 or more other quantities it
181
+ was left out. A `max_panels` below one is refused by name.
182
+ - A list or array of colours is accepted for the bars of categories only, one per
183
+ category; the other plots failed with a matplotlib error and now raise one naming the
184
+ argument, and `plot_sbc`, which coloured its rank bars from a list, refuses it too.
185
+ - A truth overlay on `which="selected"` of a fit with a `Basis` is drawn as given
186
+ without a selection and refused with one, unless the basis is the bins; it failed
187
+ with a broadcasting error or, with as many components as bins, drew a wrong overlay.
188
+ - `MAP` checks `init`'s shape and sign, and that it is not all zero, when the engine is
189
+ made; a wrong shape failed inside NumPy. EM raises zeros in its start to 1e-12 of the
190
+ largest value, so a zero, from `init` or from mix-SQP's hand-off to EM, no longer
191
+ leaves a wrong mode with only a convergence warning.
192
+ - `NUTS` checks `model`, and the shape and finiteness of `init_x`, when it is made.
193
+ - The start for rates with a selection is near the mode for broad likelihoods too.
194
+ - Gibbs refuses a negative `n_warmup`; `Laplace.run` with fewer than 3 samples draws 5
195
+ importance proposals rather than failing in Pareto smoothing; the
196
+ engines that can infer a selection are each named once in the refusal of those that
197
+ cannot.
198
+ - `Response(matrix, efficiency=...)` divides a migration column that sums to one within
199
+ `MIGRATION_ATOL` by its sum, so the efficiency given is exact.
200
+ - Boolean category labels reload as booleans; they came back as 0 and 1.
201
+ - Errors name the input at fault: a single distribution passed to `from_density`;
202
+ objects in a measured bin whose response row is zero (the error suggested
203
+ `drop_empty`); a truth bin whose response column sums to zero (the error spoke of
204
+ selection values), and any selection value that is zero or not finite;
205
+ `Response.from_counts` with more counts than generated events;
206
+ `Response.from_simulation` with `open_ended` and categorical measured bins (an
207
+ `AttributeError`); labelled scores that are not finite. `Selection.combined` checks
208
+ `scale` before evaluating its functions.
209
+ - Adaptive bin averages refine a row whose 5-point estimates are all zero where a check
210
+ rule reads something, until its cells are below `tol` of their bin, and warn where
211
+ the function is still unread there; such a row was read as zero, so a selection
212
+ function, or a bounded density, that is non-zero only within 4.7% of a bin edge was
213
+ missed without a warning.
214
+ - `check()` computes and checks the tail ESS of a selection or response inferred with the
215
+ population (`ess_tail_selection`, `ess_tail_response`); it looked for these keys, which
216
+ were never computed.
217
+ - `mock_1d` draws posterior samples flat in u within each bin when the interim prior is
218
+ omitted or known only per bin (masses or "flat"), as `Likelihoods.from_samples` reads
219
+ them; without an interim, `mock.interim` holds `Density.flat()`'s masses. On log bins
220
+ the likelihoods built from these samples were biased; linear bins are unchanged.
221
+ - `summary(level=)`, `coverage(levels=)` and `plot(levels=)` refuse levels outside
222
+ (0, 1) by name, as `interval` does.
223
+ - `rhat` of a constant chain is NaN without NumPy's "All-NaN" warning.
224
+ - `exact_posterior` refuses a `prior` given with a `PopulationModel`, which ignored it.
225
+ - `psis` refuses +inf log weights; it gave them zero weight.
226
+ - `autocorr_time` and `autocorr_function` return NaN for a constant chain; they gave 1,
227
+ or the chain's length when its mean was off by round-off.
228
+ - `mock_categorical` checks that `prevalence` and `train_prior` have `n_classes`
229
+ non-negative entries with a positive sum, naming them.
230
+ - The ECDF p-value is documented as the Bonferroni bound below 1e-12, and Pareto
231
+ smoothing as needing at least 21 weights; with fewer, k̂ = inf and the weights are not
232
+ smoothed.
233
+ - Unpickled `Bins`, and copies of grids with a non-linear measure, had writeable edges.
234
+ - `Bins.linear`, `Bins.log` and `Bins.coarsen` refuse a count or factor that is not a
235
+ positive integer, naming it; they truncated it, and `coarsen(1.5)` returned the bins
236
+ unchanged. `Bins.categories(2.0)` raises a TypeError naming `labels`.
237
+ - `PopulationModel.expected_counts` raises, naming the objects of zero likelihood, and
238
+ checks `value`; it returned zeros for them.
239
+ - `missing_information(include_prior=True)` adds a `GammaRates` prior's pseudo-counts as
240
+ the MAP EM does: 0.49 instead of 0.89 for `GammaRates(200, 1)`, which corrects the
241
+ missing information reported when the rates EM does not converge. It is NaN where
242
+ shapes below one outweigh the data.
243
+ - A distribution with `cdf` and `sf` but no `logsf` keeps its upper tail.
244
+ - `Likelihoods.from_samples` names the measure when a sample falls where a
245
+ `Measure.transform` has no finite slope, and `Measure.log_jacobian` no longer emits
246
+ NumPy warnings there.
247
+ - The docs of `tol`, of `PopulationModel(bins=)` and of `kkt_gap(include_prior=)` say
248
+ what the code does.
249
+ - A prior's fingerprint, which `attach` compares after `load`, includes the values of its
250
+ base measure: priors with different base arrays of the same length no longer pass for
251
+ each other, and a named function as base matches in another process.
252
+ - MAP with a tree prior one of whose branches has exponent zero, such as
253
+ `PolyaTree(c=K/2)`, converges when that branch's bins are empty: the KKT gap is checked
254
+ on the tree's branch probabilities, where it keeps its precision; EM warned that it had
255
+ not converged (at K = 32 also in 0.1.0).
256
+ - A value that is not numbers, such as `Dirichlet("reference")`, raises an error naming
257
+ the argument rather than NumPy's cast error.
258
+ - `infer` and `Auto.run` refuse an `n_samples` that is not a positive integer, by name;
259
+ `0` under auto ran at the automatic length.
260
+ - `Dirichlet.from_counts` refuses a negative `strength` or `base`, naming them; a negative
261
+ strength subtracted the reference sample.
262
+ - auto reported "the only engine that takes these options" when Gibbs took them but a
263
+ rule left it out.
264
+ - `amplitude`, `scale` and `length_scale` (and `length_scale[d]`) are named in their
265
+ errors.
266
+ - The docs say which priors have unbounded densities, give `GeneralizedDirichlet`'s
267
+ default `b_k = (K - k) a`, and the length scale below which `LogisticGP` warns.
268
+ - Docs: the Laplace Student-t's (−H)⁻¹ is its scale matrix, not its covariance; also
269
+ `_HESSIAN_MAX_DIM`'s description, bootstrap's `tol`, MAP's `max_iter` (which covers
270
+ mix-SQP) and the engines' notation.
271
+
272
+ ## [0.1.0] - 2026-10-29
273
+
274
+ First release.
275
+
276
+ ### Changed (landing on `main`)
277
+
278
+ - Renamed from `pastry` to `binference` (package, import and PyPI name).
279
+ The warning base class is `BinferenceWarning` and the environment variables start
280
+ with `BINFERENCE_`.
281
+
282
+ - Python ≥ 3.13, NumPy ≥ 2.1, SciPy ≥ 1.14.1, matplotlib ≥ 3.9.2.
283
+ - CI runs the pre-commit hooks, the fast suite on three systems with Python 3.13 and
284
+ 3.14, minimum dependencies, the README and user-guide code, the docs build and a
285
+ clean-wheel import; pushes to `main` publish the docs to GitHub Pages.
286
+ - Releases: a tag `vX.Y.Z` on `main` publishes to PyPI by trusted publishing.
287
+ - Development process: issue and pull-request templates and the rules in `CLAUDE.md` and
288
+ `CONTRIBUTING.md`.
289
+ - The prior base class is now `binference.priors.PopulationPrior` (was `Prior`).
290
+ - On log bins, the default base measures of `Dirichlet.from_base_measure` and
291
+ `PolyaTree`, the default mean of the logistic priors and the "flat" interim prior
292
+ are flat in log z (they were flat in z).
293
+ - Results (audit O-1–O-21): a result keeps its selection through `save`,
294
+ `load` and `attach`, which refuses other bins or another selection;
295
+ `result_to_dict` is what `save` writes (`meta` plus arrays, `label_draws` apart from
296
+ the bin labels); `check()` also flags tail ESS, E-BFMI, one-chain R-hat and
297
+ unconverged optimisers and raises `DiagnosticsError` when strict; `summary` reports
298
+ the mixing of the quantity it summarises; `which=` takes `"fraction(s)"`/`"rate(s)"`
299
+ everywhere, including `functional`, `rebin`, `cov`, `corr`, `plot_corner` and
300
+ `plot_trace`; `method="em"` runs EM on the simplex, and an explicit
301
+ `MAP(algorithm=)` raises where it cannot run instead of falling back to L-BFGS
302
+ (#100); `sample_assignments`, `sample_values` and `realized_counts` default to 500
303
+ draws; `binference.plotting` and `binference.io` load on first use;
304
+ `result.plot_individual`; `PopulationEstimator` works with
305
+ scikit-learn model selection (`Likelihoods.shape`); the xarray export uses ArviZ's
306
+ statistic names, numeric bin centres and hyperparameter draws.
307
+ - `infer` defaults to `method="auto"` (was `"nuts"`): Gibbs for
308
+ joint conjugate models and for conjugate priors with at most 0.98 missing
309
+ information (run long enough for a bulk ESS of about 400), else Laplace when its
310
+ importance check passes with an ESS of at least 400, else NUTS. The choice and
311
+ reason are in `result.info["auto_method"]` and `["auto_reason"]`. The rules are one
312
+ engine, `binference.inference.Auto`, whose thresholds (`target_ess`,
313
+ `gibbs_max_missing`, `nnz_limit`) are options; `PopulationEstimator` defaults to it
314
+ too. Pass `method="nuts"` for the previous behaviour. Without `n_samples`, a Gibbs run
315
+ chosen by auto is extended until its ESS and R-hat pass, or gives way to the next
316
+ engine beyond `max_gibbs_draws`. Laplace draws that auto keeps
317
+ without passing its check (on very large inputs, or as the last candidate) are flagged
318
+ `approximate`.
319
+ - `Laplace` finds its mode and curvature once per engine (and `step`), not on every
320
+ `run`.
321
+ - `PopulationResult.log_predictive` works through the objects `chunk` at a time (a new
322
+ `chunk` argument, 4096 by default, as `predict_proba` and
323
+ `assignment_probabilities` already did), so its memory no longer grows with the
324
+ number of objects times the number of draws.
325
+
326
+ - Names: `sbc` and `coverage` take `progress=` (was `progress_bar=`);
327
+ `CoverageResult.coverage_rates()` (was `rates()`); `Likelihoods.with_weights(
328
+ fractional_weights=)` (was `fractional=`); `simulate.mock_unfolding(n_objects=)` (was
329
+ `n_events=`). Plots label rates `lambda[k]`, as SBC names them (was `rate[k]`). The
330
+ `"se"` kernel alias and the rename hints for the old selection modes are gone.
331
+ - `Gibbs` and `MeanFieldVB` raise `ValueError` (was `TypeError`) for a model they cannot
332
+ run, with the reason `Engine.unsupported(model)` gives.
333
+ - `PopulationModel.stack()` is removed; `likelihoods.stack()` is the one stacking.
334
+ - Engines declare `Engine.markov` (draws are Markov chains, checked by R-hat and ESS)
335
+ and `Engine.unsupported(model)`; `PopulationResult(kind=)` defaults to the model's
336
+ kind; `diagnostics.importance_ess(weights)` is Kish's effective sample size.
337
+ - The chunked kernels work through 4096 dense rows at a time (was 65,536): Gibbs drew
338
+ labels as fast at either size (N = 2·10⁴ to 2·10⁵, K = 20 to 80) with 16 times less
339
+ memory per block. Sparse rows are sampled all at once, since slicing CSR rows per chunk
340
+ cost time (0.030 s per label draw, from 0.035 s, at N = 2·10⁵, K = 200, 2% filled).
341
+ - Faster: Laplace's importance step evaluates its proposals in blocks (5.3 s, from
342
+ 28.4 s, for 8000 proposals at N = 10⁵, K = 50, one thread); EM computes `L·ρ` once per
343
+ point; leave-one-out smooths all objects' weights together (3.1 s, from 7.4 s, at
344
+ N = 2·10⁴ with 2000 draws); Gibbs draws labels in place (35 ms, from 47 ms, per draw
345
+ at N = 10⁵, K = 50). `method="auto"` keeps the MAP it computed as `result.best` when that raised no
346
+ warning.
347
+ - Plot colours follow the active matplotlib style instead of fixed hex colours; new
348
+ `sample_color` argument on `plot_population` and `plot_individual`; `color` defaults to
349
+ the style and is added to `plot_individual` and `plot_sbc`; 2-D maps and the corner
350
+ plot's 2-D histograms are drawn on ramps to the population colour (relative uncertainty
351
+ to the text colour) instead of viridis, magma and Blues; `POSTERIOR_COLOR`, `STACK_COLOR` and `INK` are removed.
352
+
353
+ ### Fixed (phase-wide review)
354
+
355
+ - PSIS compared weights with the cut as `log(exp(cut))`, so a weight tied with the cut
356
+ could enter the tail with no exceedance; with duplicated draws (resampled Laplace) the
357
+ fit divided by zero. The cut is compared in logs, as ArviZ does; k-hat changes slightly
358
+ where the old comparison included the cut weight.
359
+ - A degenerate generalised-Pareto fit gives k-hat = inf in `diagnostics.psis` (was NaN,
360
+ which compared False with any threshold), so leave-one-out flags such objects.
361
+ - Bootstrap and other resampling of a model with an inferred response kept each row's
362
+ measured bin from before rows were dropped.
363
+ - `attach` clears everything computed from the previous likelihoods (the total, the
364
+ missing information); a model with another prior than the fit's no longer stands in for
365
+ it in `best` and `binning_bias` (compared by a digest of the prior's arguments, saved
366
+ with the result, since its repr shortens arrays); a saved selection on a basis
367
+ re-attaches after load.
368
+ - `save` keeps the unconstrained draws, so `prior_information_ratio` is the same after
369
+ `load`.
370
+ - `PopulationResult.from_samples` refuses a model that infers its selection or response
371
+ unless their draws are given.
372
+ - Diagnostics of a jointly inferred response are named `*_response` (were `*_selection`).
373
+ - Posterior-sample mocks on unequal bins weighted every grid step alike, whatever its
374
+ width (with bins [0, 0.1, 3], half the samples fell in the narrow bin). Their grid is
375
+ now 50 equal steps per bin in the bins' measure (in log z on log bins; was in z).
376
+ - `Selection.draw` floors its Beta draws as Gibbs does, so none underflows to zero.
377
+ - Pickling likelihoods whose within-bin data cannot be pickled warns (they were dropped
378
+ silently).
379
+
380
+ ### Added
381
+
382
+ - `benchmarks/matrix.py`: the benchmark matrix of scenario × prior × engine against
383
+ long reference runs, with its results in `benchmarks/results/`.
384
+
385
+ - **Results**: `result.selected` (the selected
386
+ population, also `which="selected"`), `realized_counts(full=True)` (with the missed
387
+ objects), `data_support` and the `support` summary column, `prior_information_ratio()`
388
+ (Efron's ratio), `check(support_min=)`, and `PointEstimate.check()` for the KKT gap.
389
+ - **Binning-bias check**: `result.binning_bias()` refits the
390
+ data on linear B-spline components over the same bins (Gaussian inputs rebuild
391
+ themselves; others take `build`) and reports each bin's shift in posterior s.d. and,
392
+ for flagged bins, `n_crit`, the number of objects at which the binning bias equals
393
+ the statistical error.
394
+ - **Best fit and leave-one-out**: every result has
395
+ `result.best` (the MAP estimate, computed on first use) and per-object outputs at it
396
+ with a `_best` suffix; `assignment_probabilities_loo` gives leave-one-out posteriors
397
+ by Pareto-smoothed importance sampling, with the Pareto k-hat per object.
398
+ - **Value draws from within-bin information**: `sample_values`
399
+ resamples the samples of `from_samples` inside the drawn bin (`keep_samples=`),
400
+ evaluates `from_density` densities inside 1-D bins (interim divided out for
401
+ posteriors), and draws correlated Gaussians jointly by Gibbs sweeps (`n_sweeps=`);
402
+ tables, binned inputs, compressed rows, densities on grids or without a pdf, samples
403
+ not kept and density functions that could not be pickled fall back to flat within
404
+ the bin, with a warning naming the source.
405
+
406
+ - **Measures**: each grid axis has a `Measure`, the coordinate
407
+ `u = T(z)` in which the population is flat within a bin: linear, log, a transform with
408
+ its inverse, or the cumulative integral of a positive density. `Bins.log` uses the log
409
+ measure; bin centres are midpoints in `u`; `Bins.from_centers` takes midpoints in `u`
410
+ (positive edges for log-spaced centres, I-16). Geometric hand-built edges warn.
411
+ - **Selection from injections**: `Selection.from_injections`
412
+ gives a completeness with Beta posteriors per bin, inferred jointly with the population
413
+ by Gibbs, NUTS, Laplace and `MAP(space="unconstrained")` (logit S as extra
414
+ coordinates); `smooth=τ` ties neighbouring bins by a random walk on logit S;
415
+ `at_mean()` fixes it for VB and the bootstrap.
416
+ - **Responses inferred with the population**: a response tallied
417
+ from events (`Response.from_counts`, `from_simulation`, `from_labelled`) has a
418
+ Dirichlet posterior per column (`prior=β`, default 1 per cell) and is inferred jointly
419
+ by Gibbs, NUTS, Laplace and unconstrained MAP; `response.fixed()` takes it as known.
420
+ - **Totals and rates from fractions**: every fractions result has
421
+ `total` (draws of Λ ~ Gamma(W, S·ρ), exact under a scale-free prior) and `rates`
422
+ (Λρ), with an absolute or no selection; point estimates give W/(S·ρ̂).
423
+ - **Mixture basis and internal resolution**:
424
+ `binference.Basis(bins, order=0|1, resolution=r)` fits components on the bins refined
425
+ `r` times, flat (`order=0`) or linear B-spline hats (`order=1`), and reports in the
426
+ bins. Every constructor takes a `Basis` for `bins` (`Likelihoods.on_basis` for
427
+ per-bin likelihoods); callable selections are averaged with each component as the
428
+ weight. Results report per bin and keep `component_draws`; save and load keep the
429
+ basis. `Bins.refine` is the counterpart of `coarsen`. `sample_values` on non-linear
430
+ measures now draws flat in `u` within a bin (it ignored `T'(z)`).
431
+ - `from_samples` stores likelihoods sparsely below 10% non-zero entries (was 30%).
432
+ - **Masked grids**: `mask=` on `Bins`, `Bins.grid`, `Bins.linear` and
433
+ `Bins.log`; masked cells leave the support and the model. Saved and loaded with
434
+ results.
435
+ - `Bins` with edges `-0.0` and `0.0` now hash alike (I-12); `Bins.index` refuses
436
+ multi-column values for 1-D bins (I-22).
437
+ - **`Density`**: one fixed density over the bin coordinate for
438
+ interim priors, the Dirichlet base measure and simulation truth. `Density.flat()` is
439
+ flat in the measure coordinate. An array interim prior on unequal bins needs
440
+ `interim_representation`, so every constructor reads it the same way (I-1); a
441
+ callable on categories receives the labels (I-17).
442
+ - `Likelihoods.stack()` uses the interim prior the likelihoods were built with
443
+ (I-5) and raises on rows with no support under it (I-6).
444
+ - **Constructors by input form**: `Likelihoods.from_table` and
445
+ `Likelihoods.from_density` replace `from_posteriors`, `from_function` and
446
+ `from_distributions`; each needs `kind="likelihood"` or `interim=`. `interim_prior`
447
+ is now `interim` (also in `stack()` and `simulate.mock_1d`).
448
+ - **Adaptive quadrature**: bin averages of functions and distributions
449
+ are refined to `tol` (default 1e-3), in the measure coordinate for likelihoods; `from_gaussian` averages in u on non-linear axes. Far tails no longer
450
+ underflow to empty rows (I-2, I-3).
451
+ - **Samples**: one estimator for every interim prior (per-sample
452
+ weights T'(z)/π(z); a per-bin prior is flat in u within bins), an opt-in Dirichlet
453
+ `floor` in pseudo-samples,
454
+ `n_eff` inside the bins with a warning on the share of noisy objects (I-23),
455
+ `Likelihoods.sample_variance` and a Monte Carlo variance check in `result.check()`;
456
+ `Measure.log_jacobian`.
457
+ - **Binned measurements**: `binference.Response` holds
458
+ P(measured bin, observed | true bin) with real truth bins, from a matrix, tallies
459
+ (`Response.from_counts`), simulated events (`Response.from_simulation`) or a labelled
460
+ validation set (`Response.from_labelled`: open-ended score bins or a confusion matrix).
461
+ `Likelihoods.from_binned` replaces `from_response`; `from_classifier` is removed
462
+ (route A is `from_table` on categories, route C is `from_binned` with a labelled
463
+ response). `summary()` names the inputs, and `result.check()` runs a posterior
464
+ predictive test of the measured counts (`Response.predictive_pvalue`) that flags label
465
+ shift. `check()` raises `InputWarning` for problems with the inputs (this test and the
466
+ samples' Monte Carlo variance) and `ConvergenceWarning` for sampler problems. `simulate.mock_categorical` gains `temperature` and a labelled `mock.response`;
467
+ `simulate.mock_unfolding` returns `mock.response`.
468
+ - **Selection**: the modes are
469
+ `"on_truth"` and `"on_measurement"` (the old names raise an error naming the new
470
+ ones); `Selection.combined(on_truth, on_measurement)` selects on both; a selection may
471
+ be a function of the true value, averaged over each bin (`Selection.from_function`,
472
+ or a callable `selection=`); values are detection probabilities in (0, 1] unless
473
+ declared `scale="exposure"` or `"relative"`, and rates refuse a relative selection
474
+ (audit G-4); an array that changes by more than a factor of two between neighbouring
475
+ bins raises an `InputWarning` (a `Selection` object or a callable is taken as averaged
476
+ within bins).
477
+ `simulate.mock_1d(measured_range=...)` simulates selection on the measurement, alone
478
+ or with `selection=` (combined). `sbc`/`coverage` name rates `lambda[k]` (G-10).
479
+ - **Model**: `PopulationModel.log_prob` and
480
+ `log_prob_and_grad` are renamed `log_density_unconstrained` and
481
+ `log_density_unconstrained_and_grad`; the theory page explains the two densities
482
+ and their modes. `kkt_gap` is infinite where an object is impossible and, for rates,
483
+ relative to the exposure (audit M-3, M-4); `missing_information` is correct with a
484
+ selection function and on the support, with `include_prior=` for the MAP EM (M-2).
485
+ Bootstrap replicates drop zero-weight objects in every engine, so EM no longer
486
+ resets to the prior's mode or collapses rates to zero (M-1); EM stops with a warning
487
+ where an object becomes impossible. The rates starting point is W ρ / S (M-7).
488
+ `LogisticGP()` works on two bins (M-14). `PopulationResult.log_prob` is now
489
+ `log_density_unconstrained` (old files still load); `MAP.run` no longer takes
490
+ `weights=`.
491
+ - **MAP**: `tol` (default 1e-8, was 1e-10 on the objective) is the
492
+ tolerance on the KKT gap for every simplex algorithm and on the largest gradient over
493
+ `max(1, W)` for L-BFGS (mix-SQP bounds the gap of the problem it solves), and EM is
494
+ converged only when the gap is below it, or below `1e3 * tol` once the objective
495
+ stops improving (M-6, M-9).
496
+ `GammaRates` with shapes of at least one use mix-SQP, with the total rate profiled
497
+ out (M-6). `PointEstimate.log_posterior` is `model.log_posterior(value)` for every
498
+ algorithm (NaN for priors without a closed-form density); L-BFGS adds
499
+ `info["log_density_unconstrained"]` (M-8). mix-SQP drops its SVD and starts after
500
+ 10 EM steps instead of 50, 2–3 times faster on large dense inputs (M-5); a failed
501
+ quadratic step hands over to EM instead of raising (M-13); Dirichlet priors
502
+ mixing concentrations of one and above one no longer warn (T-4). The rates KKT gap
503
+ is one-sided, so a rate EM drives towards zero no longer reads as a violation.
504
+ - **Priors**: `LogisticRandomWalk(trend_scale=3.0)` is the standard
505
+ deviation of each unpenalised mode's root-mean-square size across the grid, so its
506
+ meaning no longer depends on K (was 10 in basis units, which tightened as 1/√K; P-6).
507
+ Arguments are checked when a prior is made: `DirichletTree` per-node alphas of
508
+ different lengths now work (P-4), `LogisticNormal(cov=)` must be a positive variance
509
+ or a matrix positive semi-definite on zero-sum vectors (P-8), `LogisticGP` `n_basis`
510
+ and `boundary_factor` are checked and `length_scale` takes an array (P-10, P-11),
511
+ `PolyaTree` needs two bins and a non-negative power (P-9), `GeneralizedDirichlet`
512
+ `a`, `b` and `order` are checked (P-22). Reprs show every argument (P-14); tree VB
513
+ draws have no exact zeros (P-12); `GammaRates` has a `prior_transform` (P-15).
514
+ `GeneralizedDirichlet` and `PolyaTree` are no longer subclasses of `DirichletTree`
515
+ (P-13). `LogisticRandomWalk(2).bind` at K = 1000 and 20,000 GP draws are about twice
516
+ as fast (P-20).
517
+ - **GP prior**: `LogisticGP` is stationary in the measure coordinate
518
+ (log z on `Bins.log`; length scales are in that coordinate; P-1). Defaults:
519
+ `boundary_factor=3` (was 1.5; P-3), `n_basis` one per bin up to 1024 modes in all
520
+ (was at most 48 per axis), and a
521
+ length-scale prior whose lower 1% quantile is the shortest length scale that basis
522
+ resolves (P-2), or `LogNormal(log(range/2), 1)` on coarse grids (P-7). Partially
523
+ centred GP densities and gradients agree where scales underflow (P-5).
524
+ - **NUTS and Laplace**: NUTS results (`x`, `log_density_unconstrained`,
525
+ `model`) and the positions `sample()` yields are in the model's own coordinates, not
526
+ the partly centred sampling ones (`info["centring"]` holds the weights; N-1, N-2).
527
+ `diagnostics.psis_threshold(n)` gives the k̂ threshold for n importance weights. Parallel workers receive the model
528
+ once, reuse one pool per run, never raise a BLAS thread limit already set, respect
529
+ CPU affinity, and errors from the model are raised instead of triggering a serial
530
+ rerun (N-3, N-7, N-13). `max_depth`, `n_warmup`, `jitter` and `init` are checked
531
+ (N-5); Laplace returns every draw asked for without importance resampling (N-4) and
532
+ judges k̂ against min(1 − 1/log10 S, 0.7) (N-6). Dense momentum draws use a
533
+ precomputed triangular factor (N-9).
534
+ - **Validation, Gibbs, bootstrap**: SBC p-values and bands use the
535
+ expected count per rank bin (G-1) and `sbc` warns when the ESS is below `n_draws` (G-9);
536
+ `exact_posterior` integrates by stick-breaking Gauss–Legendre quadrature that resolves
537
+ the simplex boundary, also for concentrations below one, adds `log_density`, and bounds
538
+ its memory, with a default `n_grid` of 200 (G-3, G-5); weighted Gibbs on sparse
539
+ likelihoods draws counts over each row's nonzeros only (G-2); Gibbs checks `chunk`,
540
+ `store_labels` and `init`, and chains start apart, from counts that include missed
541
+ objects (G-6, G-7); SBC rejects `n_bins` above `n_draws + 1`; `Bootstrap(kind=)` is now
542
+ `scheme=`, non-converged replicates are counted and the base fit warns (G-8).
543
+ - **Correlated Gaussians**: `from_gaussian(..., cov=)` takes full
544
+ per-object covariances, averaged over N-D bins by adaptive cubature in log space.
545
+ - `weights` are integer multiplicities; non-integer weights need `fractional_weights=True`
546
+ and warn that the result is a pseudo-likelihood. Stored arrays
547
+ are read-only (I-14); `compress()` keeps sparse storage and is fast on it (I-7, I-19);
548
+ warnings point at the caller's line; clearer errors for bad `rtol`, Gaussian shapes,
549
+ zero objects and 2-D arrays passed to `Bins.grid` (I-8, I-10, I-11, I-20); broad
550
+ Gaussians keep full precision near the mean (I-15).
551
+ - Each object's likelihood mass outside the bins is recorded in
552
+ `meta["outside_fraction"]`, with a warning when many objects lose most of it.
553
+
554
+ - **Inputs.** `Bins` (linear, log, from centres, N-D grids, categories) and
555
+ `Likelihoods` with constructors for:
556
+ - likelihood matrices (density or mass representation, dense or sparse,
557
+ log-space input);
558
+ - Gaussian measurements;
559
+ - per-object posteriors with their interim prior;
560
+ - posterior samples;
561
+ - SciPy distributions and arbitrary likelihood functions;
562
+ - response matrices (unfolding) and classifier scores or labels (quantification),
563
+ as binned measurements with a `Response`.
564
+ - **Selection.** `Selection` functions with explicit `"on_measurement"` and
565
+ `"on_truth"` modes, attached to the data or passed to the model.
566
+ - **Model.** `PopulationModel` for bin fractions or Poisson rates, with
567
+ log-density and gradient in unconstrained coordinates, expected counts,
568
+ responsibilities, an optimality (KKT) gap and the missing-information fraction.
569
+ - **Priors.**
570
+ - Simplex: `Dirichlet` (with reference, count-based and base-measure
571
+ constructors), `GeneralizedDirichlet`, `DirichletTree`, `PolyaTree`.
572
+ - Smoothness: `LogisticNormal`, `LogisticRandomWalk` and `LogisticGP`
573
+ (Hilbert-space GP) on N-D grids, with inferred hyperparameters.
574
+ - Rates: `GammaRates`.
575
+ - **Engines.**
576
+ - `NUTS`: multinomial NUTS with windowed metric adaptation.
577
+ Smoothness priors get partial non-centring (where the data constrain
578
+ their scales) and a curvature-based dense metric. Chains are resumable
579
+ and can run in parallel processes, which share the cores' BLAS threads
580
+ (via `threadpoolctl`) rather than oversubscribing them.
581
+ - Data-augmentation `Gibbs` for conjugate priors, with selection augmentation.
582
+ - `MAP` with an optimality certificate: mix-SQP for Dirichlet priors with
583
+ concentrations of at least one (under a fixed selection only `Dirichlet(1)`, which
584
+ gives maximum likelihood) and for `GammaRates` with shapes of at least one;
585
+ SQUAREM-accelerated EM for the other conjugate priors whose density is bounded;
586
+ L-BFGS otherwise.
587
+ - `Laplace` with PSIS importance correction.
588
+ - `MeanFieldVB` (flagged as approximate) and `Bootstrap` (nonparametric or
589
+ Bayesian, over objects, with variable totals for rate models).
590
+ - **Interfaces.** `binference.infer` and the scikit-learn-style `PopulationEstimator`.
591
+ - **Results.** `PopulationResult` and `PointEstimate` provide:
592
+ - summaries, intervals (central and HDI), functionals and rebinning;
593
+ - per-object assignment probabilities, values and realised counts;
594
+ - posterior predictive scores, diagnostics and checks with hints;
595
+ - plots, save/load and xarray `DataTree` export.
596
+ - **Diagnostics.** Rank-normalised split R-hat, bulk and tail ESS,
597
+ autocorrelation time, MCSE and PSIS.
598
+ - **Validation.** Exact quadrature posteriors (K <= 3), simulation-based
599
+ calibration and coverage studies. Mock catalogues in 1-D and 2-D, plus
600
+ categorical, unfolding and prior-predictive mocks.
601
+ - **Design documents, tests, docs.**
602
+ - Specification, test plan, implementation plan, and a survey of related
603
+ software, including an audit of the `frankenz` samplers.
604
+ - A fast and a slow (statistical) test suite.
605
+ - Sphinx documentation with tutorials.
@@ -10,8 +10,8 @@ type: software
10
10
  authors:
11
11
  - family-names: Speagle
12
12
  given-names: Joshua S.
13
- version: 0.1.0
14
- date-released: 2026-10-29
13
+ version: 0.2.0
14
+ date-released: 2026-11-07
15
15
  license: MIT
16
16
  repository-code: "https://github.com/joshspeagle/binference"
17
17
  keywords:
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2018 Josh Speagle
3
+ Copyright (c) 2018-2026 Josh Speagle
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: binference
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: Population and hierarchical inference with PDFs: honest population distributions from noisy per-object PDFs over bins.
5
5
  Project-URL: Homepage, https://github.com/joshspeagle/binference
6
6
  Project-URL: Source, https://github.com/joshspeagle/binference
@@ -36,6 +36,7 @@ Requires-Dist: numpydoc>=1.6; extra == 'dev'
36
36
  Requires-Dist: pre-commit>=3; extra == 'dev'
37
37
  Requires-Dist: pytest-cov>=5; extra == 'dev'
38
38
  Requires-Dist: pytest>=8; extra == 'dev'
39
+ Requires-Dist: scikit-learn>=1.6; extra == 'dev'
39
40
  Requires-Dist: sphinx-copybutton>=0.5; extra == 'dev'
40
41
  Requires-Dist: sphinx>=7.2; extra == 'dev'
41
42
  Requires-Dist: sphinxcontrib-bibtex>=2.6; extra == 'dev'
@@ -55,6 +56,7 @@ Provides-Extra: test
55
56
  Requires-Dist: matplotlib>=3.9.2; extra == 'test'
56
57
  Requires-Dist: pytest-cov>=5; extra == 'test'
57
58
  Requires-Dist: pytest>=8; extra == 'test'
59
+ Requires-Dist: scikit-learn>=1.6; extra == 'test'
58
60
  Provides-Extra: xarray
59
61
  Requires-Dist: xarray>=2024.10; extra == 'xarray'
60
62
  Description-Content-Type: text/markdown