Probability mass functions #
This file is about probability mass functions or discrete probability measures:
a function α → ℝ≥0
such that the values have (infinite) sum 1
.
This file features the monadic structure of pmf
and the Bernoulli distribution
Implementation Notes #
This file is not yet connected to the measure_theory
library in any way.
At some point we need to define a measure
from a pmf
and prove the appropriate lemmas about
that.
Tags #
probability mass function, discrete probability measure, bernoulli distribution
bind_on_support
reduces to bind
if f
doesn't depend on the additional hypothesis
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), _⟩
Given a finite type α
and a function f : α → ℝ≥0
with sum 1, we get a pmf
.
Equations
- pmf.of_fintype f h = ⟨f, _⟩
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)) _