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
¶
prob(f: Morphism, domain_indices: Tensor, codomain_indices: Tensor) -> Tensor
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
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | |
marginal_prob
¶
marginal_prob(f: Morphism, codomain_indices: Tensor) -> Tensor
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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 | |
expectation
¶
expectation(f: Morphism, values: Tensor) -> Tensor
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
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |