_Posterior
Conjugate updating: posterior(prior, likelihood, data) (F_0050).
The likelihood is written as the family with its unknown parameter left free — posterior(betadist(2, 2), binomial(10, p), 7) — where p is the one free name, the same exactly-one-free-name rule Predicate applies to a random variable. The answer is an ordinary _Distribution, so pdf/cdf/quantile/expect/variance apply to it unchanged and nothing downstream learns a new type.
The table, each arm validating its data:
| prior | likelihood (free) | data | posterior |
|---|---|---|---|
betadist(a, b) |
binomial(n, p) |
a count k in 0..n |
betadist(a + k, b + n − k) |
gammadist(k, rate) |
poisson(l) |
observations, non-negative integers | gammadist(k + Σx, rate + n) |
normal(μ₀, σ₀) |
normal(μ, σ), σ known |
observations | precision-weighted normal(μₙ, σₙ) |
Observations are a 1×n row or an n×1 column; a single number is a sample of one.
Everything else stays symbolic: a pair outside the table, two free names or none, a likelihood whose free slot is not the conjugate parameter (binomial(n, 0.5)), the Normal–Normal case with unknown σ (that needs the Normal-inverse-gamma family, a two-parameter carrier this package does not have), and invalid data. A general posterior — an unnormalised density with no closed form — is deliberately not attempted: it needs numerical integration over the parameter space or sampling, which is a package rather than a function, and declining beats a confident approximation.
Exactness: a _Distribution stores Double parameters, so a conjugate posterior is a Double result even from exact input — the lu/qr precedent, demote rather than refuse. Only _Bayes is exact.
Value parameters
- data
-
the observation: a count, a number, or a vector of observations
- likelihood
-
the sampling family with its unknown parameter free
- prior
-
a distribution expression, the prior
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass Any