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.
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
Create new PMF
by filtering on a set with non-zero measure and normalizing.
Equations
- p.filter s h = PMF.normalize (s.indicator ⇑p) ⋯ ⋯
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) ⋯