_Bayes
Bayes' theorem over a finite set of hypotheses: bayes(prior, likelihood) (F_0050).
Two vectors of the same shape — a 1×n row or an n×1 column — give the normalised posterior pᵢ·Lᵢ / Σⱼ pⱼ·Lⱼ, in that same shape. No new carrier was needed: a row is what tabulate and eigen already return, and it is the form every textbook opens with.
Exact on exact input. When every entry of both vectors is a core._Rational the posterior is computed over the rationals and returned as the prior's own node rebuilt with exact cells, so a posterior of fractions stays a posterior of fractions; one inexact entry demotes the whole computation to Double, the float-contagion rule. The rebuild goes through the prior's core._MatrixShaped node, which is how this package yields a symbolic matrix without importing matrix.
Refuses, staying symbolic: a shape mismatch, an operand that is not a row or a column, a negative entry (neither a probability nor a likelihood), and zero evidence, Σ = 0, which has no posterior at all rather than a degenerate one.
Value parameters
- likelihood
-
the likelihood of the observation under each hypothesis, the same shape
- prior
-
the prior weights over the hypotheses, a row or a column
Attributes
- Graph
-
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait _Expressionclass Objecttrait Matchableclass Any