Monad Operations for Probability Mass Functions #
This file constructs two operations on PMF
that give it a monad structure.
pure a
is the distribution where a single value a
has probability 1
.
bind pa pb : PMF β
is the distribution given by sampling a : α
from pa : PMF α
,
and then sampling from pb a : PMF β
to get a final result b : β
.
bindOnSupport
generalizes bind
to allow binding to a partial function,
so that the second argument only needs to be defined on the support of the first argument.
The measure of a set under pure a
is 1
for sets containing a
and 0
otherwise.
The measure of a set under p.bind f
is the sum over a : α
of the probability of a
under p
times the measure of the set under f a
.
Generalized version of bind
allowing f
to only be defined on the support of p
.
p.bind f
is equivalent to p.bindOnSupport (fun a _ ↦ f a)
, see bindOnSupport_eq_bind
.
Equations
- One or more equations did not get rendered due to their size.
Instances For
bindOnSupport
reduces to bind
if f
doesn't depend on the additional hypothesis.
The measure of a set under p.bindOnSupport f
is the sum over a : α
of the probability of a
under p
times the measure of the set under f a _
.
The additional if statement is needed since f
is only a partial function.