Specific Constructions of Probability Mass Functions #
This file gives a number of different PMF constructions for common probability distributions.
map and seq allow pushing a PMF α along a function f : α → β (or distribution of
functions f : PMF (α → β)) to get a PMF β.
ofFinset and ofFintype simplify the construction of a PMF α from a function f : α → ℝ≥0∞,
by allowing the "sum equals 1" constraint to be in terms of Finset.sum instead of tsum.
normalize constructs a PMF α by normalizing a function f : α → ℝ≥0∞ by its sum,
and filter uses this to filter the support of a PMF and re-normalize the new distribution.
This instance allows do notation for PMF to be used across universes, for instance as
example {R : Type u} [Ring R] (x : PMF ℕ) : PMF R := do
let ⟨n⟩ ← ULiftable.up x
pure n
where x is in universe 0, but the return value is in universe u.
Alias of PMF.ofFinset_apply_of_notMem.
Given a finite type α and a function f : α → ℝ≥0∞ with sum 1, we get a PMF.
Equations
- PMF.ofFintype f h = PMF.ofFinset f Finset.univ h ⋯
Instances For
Alias of PMF.filter_apply_eq_zero_of_notMem.
A PMF which assigns probability p to true and 1 - p to false.
Equations
- PMF.bernoulli p h = PMF.ofFintype (fun (b : Bool) => bif b then ↑p else 1 - ↑p) ⋯