The Pólya urn #
An urn holds balls of the colours in α with positive weights θ c. Draws are made one at a
time; after n draws in which colour c came up x c times, the next draw is colour c with
probability
(θ c + x c) / (∑ θ + n),
the prediction rule of [Pit06] Exercise 2.2.2, polyaUrnPredictive. Multiplying these
probabilities along a sequence gives the probability of the sequence, which depends only on its
count vector x:
polyaUrnProb θ x = ∏ c, (θ c)_{x c} / (∑ θ)_{∑ x}
in rising factorials (a)_m = a (a + 1) ⋯ (a + m - 1) (ascPochhammer). The drawn sequence is
exchangeable, with Dirichlet-distributed limiting frequencies ([Pit06] Exercise 2.2.2).
This file is measure-free: the law of the sequence and its exchangeability are in
Linglib.Core.Probability.Distributions.PolyaUrn.
Main definitions #
ProbabilityTheory.countVec s: how often each colour occurs in the sequences.ProbabilityTheory.polyaUrnPredictive θ x c: the probability of drawingcnext.ProbabilityTheory.polyaUrnProb θ x: the probability of a sequence with count vectorx.
Main results #
ProbabilityTheory.polyaUrnProb_update_succ,ProbabilityTheory.polyaUrnProb_countVec_snoc: drawing colourcmultiplies the probability by the probability of drawingc.ProbabilityTheory.polyaUrnProb_add: conjugacy; after the countsx, the urn with weightsθ + xgives the probability of the further countsy.ProbabilityTheory.sum_polyaUrnPredictive: the prediction rule is a probability.
Implementation notes #
The weights are a plain function θ : α → ℝ, positivity being a hypothesis of the results that
need it, and updating them by observed counts is the sum θ + x. The identities between
polyaUrnProb and polyaUrnPredictive hold without hypotheses.
The partition of the draws generated by the symmetric urn with m colours of weight κ is the
Pitman–Yor partition with discount -κ and concentration m κ ([Pit06] Exercise 2.2.5
and p. 61); as κ → 0 with m κ tending to a concentration c > 0 it tends to the
discount-0 partition, generated by the Blackwell–MacQueen urn ([Pit06] Exercise 2.2.6 and
p. 61). Neither is formalized here.
References #
Count vectors #
The count vector of a sequence: how often each colour occurs in it.
Equations
- ProbabilityTheory.countVec s c = {i : Fin n | s i = c}.card
Instances For
Permuting a sequence does not change its counts.
The counts of a sequence of n draws add up to n.
The prediction rule and the probability of a sequence #
The probability that the urn with weights θ draws colour c after draws with counts x:
(θ c + x c) / (∑ θ + ∑ x) ([Pit06] Exercise 2.2.2).
Equations
- ProbabilityTheory.polyaUrnPredictive θ x c = (θ c + ↑(x c)) / (∑ i : α, θ i + ∑ i : α, ↑(x i))
Instances For
The probability that the urn with weights θ draws a given sequence with counts x.
Equations
- ProbabilityTheory.polyaUrnProb θ x = (∏ c : α, Polynomial.eval (θ c) (ascPochhammer ℝ (x c))) / Polynomial.eval (∑ c : α, θ c) (ascPochhammer ℝ (∑ c : α, x c))
Instances For
The first draw is proportional to the weights.
Drawing colour c multiplies the probability of the sequence by the probability of drawing
c: the rising-factorial recursion (a)_{m + 1} = (a)_m (a + m) at c and at the total.
Appending colour c to a sequence multiplies its probability by the probability of drawing
c.
Prepending colour c to a sequence multiplies its probability by the probability of drawing
c first given the rest; the counts do not see the order.
Conjugacy. The probability of counts x + y is the probability of x times the
probability of y under the urn whose weights are raised by x.
The prediction rule is a probability on the colours.