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 β
of_finset and of_fintype 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.
of_multiset, uniform_of_finset, and uniform_of_fintype construct probability mass functions
from the corresponding object, with proportional weighting for each element of the object.
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.
Given a finite type α and a function f : α → ℝ≥0 with sum 1, we get a pmf.
Equations
- pmf.of_fintype f h = pmf.of_finset f finset.univ h _
Given a non-empty multiset s we construct the pmf which sends a to the fraction of
elements in s that are a.
Equations
- pmf.of_multiset s hs = ⟨λ (a : α), ↑(multiset.count a s) / ↑(⇑multiset.card s), _⟩
Uniform distribution taking the same non-zero probability on the nonempty finset s
Equations
- pmf.uniform_of_finset s hs = pmf.of_finset (λ (a : α), ite (a ∈ s) (↑(s.card))⁻¹ 0) s _ _
The uniform pmf taking the same uniform value on all of the fintype α
A pmf which assigns probability p to tt and 1 - p to ff.
Equations
- pmf.bernoulli p h = pmf.of_fintype (λ (b : bool), cond b p (1 - p)) _