Queries¶
These functions compute probabilities, marginals, and expectations
from stochastic morphisms. prob reads the probability of an output given an input,
marginal_prob sums over the codomain coordinates being removed, and expectation weights values
by their probabilities (Bishop, 2006).
queries
¶
Probability queries on stochastic morphisms.
Provides functions to extract probabilities, compute marginal probabilities, and compute expected values under stochastic morphisms.
prob
¶
Extract probabilities at specific (domain, codomain) index pairs.
| PARAMETER | DESCRIPTION |
|---|---|
f
|
A (stochastic) morphism A → B.
TYPE:
|
domain_indices
|
Integer indices into the domain. Shape (batch,) or (batch, n_dom_dims).
TYPE:
|
codomain_indices
|
Integer indices into the codomain. Shape (batch,) or (batch, n_cod_dims).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Probability values at the specified index pairs. Shape (batch,). |
Source code in src/quivers/stochastic/queries.py
marginal_prob
¶
Compute marginal probability over the domain for specific codomain indices.
Marginalizes (sums) over all domain elements: P(b) = Σ_a f(a, b) / |A|
This assumes a uniform prior over the domain.
| PARAMETER | DESCRIPTION |
|---|---|
f
|
A (stochastic) morphism A → B.
TYPE:
|
codomain_indices
|
Integer indices into the codomain. Shape (batch,).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Marginal probabilities. Shape (batch,). |
Source code in src/quivers/stochastic/queries.py
expectation
¶
Compute expected value of a function under a stochastic morphism.
For each domain element a, computes: E_f[v | a] = Σ_b f(a, b) · values(b)
| PARAMETER | DESCRIPTION |
|---|---|
f
|
A (stochastic) morphism A → B.
TYPE:
|
values
|
Real-valued function on the codomain. Shape (*codomain.shape).
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Tensor
|
Expected values. Shape (*domain.shape). |
Source code in src/quivers/stochastic/queries.py
Cited sources¶
Christopher M. Bishop. Pattern Recognition and Machine Learning. Information Science and Statistics. Springer, 2006. ISBN 9780387310732. URL: https://link.springer.com/book/9780387310732.