Queries¶
Probabilistic queries and inference computations on stochastic morphisms.
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). |