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.
Equations
Given a finset s and a function f : α → ℝ≥0∞ with sum 1 on s,
such that f a = 0 for a ∉ s, we get a PMF.
Equations
- PMF.ofFinset f s h h' = { val := f, property := (_ : HasSum f 1) }
Instances For
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 (_ : ∀ a ∉ Finset.univ, f a = 0)
Instances For
Create new PMF by filtering on a set with non-zero measure and normalizing.
Equations
- PMF.filter p s h = PMF.normalize (Set.indicator s ⇑p) (_ : tsum (Set.indicator s ⇑p) ≠ 0) (_ : ∑' (a : α), Set.indicator s (⇑p) a ≠ ⊤)
Instances For
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) (_ : (Finset.sum Finset.univ fun (a : Bool) => (fun (b : Bool) => bif b then p else 1 - p) a) = 1)