Skip to content

Commit c38b5ce

Browse files
Orthant-CDF analytic arm, multinomial family, voting use case in multivalued plan
1 parent 176ef94 commit c38b5ce

1 file changed

Lines changed: 62 additions & 9 deletions

File tree

doc/TODO/multivalued-distributions.md

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,13 @@ portfolio combination) come out closed-form for free.
161161
**Later route: native vector leaves (`rv_vec` gate).** For families
162162
with no useful scalar decomposition – above all **empirical point
163163
clouds** (bags of embeddings: a categorical over points in R^d, where
164-
per-component encoding would explode into selector/case chains) and
165-
directional families (von Mises–Fisher) – a second appended gate type
164+
per-component encoding would explode into selector/case chains),
165+
directional families (von Mises–Fisher), and **multinomial count
166+
vectors** (negatively correlated components with no independent-leaf
167+
decomposition; the MC sampler draws them natively, and their Gaussian
168+
limit N(nq, n(diag(q) − qqᵀ)) is already covered by the compiled MVN,
169+
which is the right surrogate for large n anyway) – a second appended
170+
gate type
166171
`rv_vec` with `extra = "family:d:params…"` and a parallel
167172
`VectorDistribution` interface (see §5). Deliberately phased after the
168173
compile-to-scalar route ships.
@@ -225,9 +230,33 @@ schemas that lack the type:
225230
native leaf becomes a marginal-projection gate evaluated through the
226231
vector cache.
227232
- **Analytic extensions**, ordered by value: MVN differential entropy
228-
(closed form) in `InformationTheory`; Mahalanobis / squared-norm
229-
events on Gaussians (generalised chi-square CDF) in
230-
`AnalyticEvaluator`; everything else falls back to MC as usual.
233+
(closed form) in `InformationTheory`; a **Gaussian orthant-CDF arm**
234+
(see below); Mahalanobis / squared-norm events on Gaussians
235+
(generalised chi-square CDF) in `AnalyticEvaluator`; everything else
236+
falls back to MC as usual.
237+
- **Gaussian orthant CDF for correlated comparison conjunctions.** An
238+
AND-conjunction of comparison events whose operands are all affine
239+
combinations of shared Normal leaves (exactly what a compiled MVN
240+
produces) is a multivariate-normal orthant probability
241+
Φ_d(τ; μ, Σ). Today such a conjunction falls through to MC, which
242+
(a) converges at the O(N^-1/2) sampling rate when a
243+
quasi-deterministic quadrature (Genz–Bretz) evaluates the same
244+
quantity to near machine precision at O(d³)-ish cost, and (b) simply
245+
returns 0 on rare orthants (Pr ≲ 10⁻⁶ is already unresolvable at
246+
realistic sample budgets, whereas applications legitimately need
247+
10⁻¹² – rare-event workloads pair the orthant CDF with a tilted
248+
importance-sampling fallback). Shape of the fix: after the peephole
249+
has folded the affine arithmetic through the Normal sum-closure
250+
registry, detect in `AnalyticEvaluator` that every conjunct of a
251+
`walkAndConjunctIntervals`-style joint pass is a linear comparison
252+
over jointly-Gaussian scalars, assemble (μ, Σ) from the shared-leaf
253+
decomposition, and call a Genz–Bretz routine; decline to MC on any
254+
non-Gaussian leaf. This subsumes the pairwise Normal-vs-Normal
255+
closed form (d = 1) and gives "min/max/rank of correlated Gaussians"
256+
events – first-elimination / argmin probabilities, order statistics
257+
of correlated portfolio components – an exact path. Depends on the
258+
same P0 census fix; a correlated conjunction of shared-leaf
259+
comparisons is precisely the shape the sibling-arm bug corrupts.
231260
- **Prerequisite**: the HybridEvaluator sibling-arm census bug (shared
232261
leaves across sibling arms de-duplicated as if independent) must be
233262
fixed first – compiled MVNs are *made of* shared leaves, and the
@@ -323,6 +352,26 @@ is the combination with the *rest* of the provenance machinery:
323352
document; dominant-topic events via pairwise component comparisons;
324353
formula/counting semirings give the lineage and multiplicity of
325354
topic-share aggregates.
355+
6. **Election forecasting with partially observed ballots** (e.g.
356+
probabilistic ranked-choice voting: unobserved ballots as
357+
multinomial draws from a polling prior, "candidate a currently
358+
last" as the conjunction of pairwise tally comparisons). One
359+
round's elimination probabilities map cleanly onto this plan: the
360+
Gaussian surrogate of the multinomial tally vector is a compiled
361+
MVN, the pairwise differences are componentwise `gate_arith`, and
362+
the argmin event is exactly the correlated-Gaussian-conjunction
363+
shape the §5 orthant-CDF arm evaluates analytically – without that
364+
arm, MC reduces the whole exercise to naive sampling and cannot
365+
resolve the rare orthants such workloads care about. **Scope
366+
limit**, recorded so it is not rediscovered: the *multi-round*
367+
recursion (chaining stage probabilities over the 2^k survivor-set
368+
DAG, per-round re-randomisation, uniform tie-breaking among argmin
369+
candidates) is an iterative algorithm, not a query; it stays in
370+
application code that calls one-stage ProvSQL evaluations, and is
371+
not a target for the rewriter (recursive-CTE positions are anyway
372+
outside the comparison lift's supported positions). A small-k
373+
single-stage version makes a good correlated-uncertainty case
374+
study once the orthant arm exists.
326375

327376
## Priorities
328377

@@ -336,10 +385,14 @@ is the combination with the *rest* of the provenance machinery:
336385
`sum`/`avg` aggregates, pg_regress coverage.
337386
3. **P2 – UX**: Studio (§7) rendering + eval strip + capability
338387
probes; user-manual chapter; case study (Playground-seeded).
339-
4. **P3 – native vector leaves**: `rv_vec` gate + `VectorDistribution`
340-
+ sampler vector cache, `empirical_vectors` for embedding bags,
341-
chunked `set_extra`, MVN entropy + Mahalanobis analytic arms,
342-
`vector_families()`.
388+
4. **P3 – native vector leaves and analytic depth**: `rv_vec` gate +
389+
`VectorDistribution` + sampler vector cache, `empirical_vectors`
390+
for embedding bags, multinomial family, chunked `set_extra`, MVN
391+
entropy + Gaussian orthant-CDF (Genz–Bretz) + Mahalanobis analytic
392+
arms, `vector_families()`. The orthant arm is independent of the
393+
native-leaf machinery (it works on phase-1 compiled MVNs) and can
394+
be pulled forward on its own if a rare-event or argmin workload
395+
(§8.6) materialises first.
343396
5. **Demand-gated**: the `provsql_vector` ANN-indexing bridge (§2) –
344397
only if a large-corpus similarity workload shows up.
345398
6. **Research follow-ups**: copula sugar over this machinery

0 commit comments

Comments
 (0)