Monad Operations for Probability Mass Functions #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 : β.
bind_on_support 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.
Equations
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
The measure of a set under p.bind_on_support 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