# 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.

bernoulli represents the bernoulli distribution on Bool.

def PMF.map {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) :
PMF β

The functorial action of a function on a PMF.

Equations
Instances For
theorem PMF.monad_map_eq_map {α : Type u} {β : Type u} (f : αβ) (p : PMF α) :
f <\$> p = PMF.map f p
@[simp]
theorem PMF.map_apply {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) (b : β) :
(PMF.map f p) b = ∑' (a : α), if b = f a then p a else 0
@[simp]
theorem PMF.support_map {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) :
theorem PMF.mem_support_map_iff {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) (b : β) :
b PMF.support (PMF.map f p) ∃ a ∈ , f a = b
theorem PMF.bind_pure_comp {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) :
PMF.bind p (PMF.pure f) = PMF.map f p
theorem PMF.map_id {α : Type u_1} (p : PMF α) :
PMF.map id p = p
theorem PMF.map_comp {α : Type u_1} {β : Type u_2} {γ : Type u_3} (f : αβ) (p : PMF α) (g : βγ) :
PMF.map g (PMF.map f p) = PMF.map (g f) p
theorem PMF.pure_map {α : Type u_1} {β : Type u_2} (f : αβ) (a : α) :
PMF.map f () = PMF.pure (f a)
theorem PMF.map_bind {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : PMF α) (q : αPMF β) (f : βγ) :
PMF.map f (PMF.bind p q) = PMF.bind p fun (a : α) => PMF.map f (q a)
@[simp]
theorem PMF.bind_map {α : Type u_1} {β : Type u_2} {γ : Type u_3} (p : PMF α) (f : αβ) (q : βPMF γ) :
PMF.bind (PMF.map f p) q = PMF.bind p (q f)
@[simp]
theorem PMF.map_const {α : Type u_1} {β : Type u_2} (p : PMF α) (b : β) :
PMF.map () p =
@[simp]
theorem PMF.toOuterMeasure_map_apply {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) (s : Set β) :
() s = (f ⁻¹' s)
@[simp]
theorem PMF.toMeasure_map_apply {α : Type u_1} {β : Type u_2} (f : αβ) (p : PMF α) (s : Set β) [] [] (hf : ) (hs : ) :
(PMF.toMeasure (PMF.map f p)) s = () (f ⁻¹' s)
def PMF.seq {α : Type u_1} {β : Type u_2} (q : PMF (αβ)) (p : PMF α) :
PMF β

The monadic sequencing operation for PMF.

Equations
Instances For
theorem PMF.monad_seq_eq_seq {α : Type u} {β : Type u} (q : PMF (αβ)) (p : PMF α) :
(Seq.seq q fun (x : Unit) => p) = PMF.seq q p
@[simp]
theorem PMF.seq_apply {α : Type u_1} {β : Type u_2} (q : PMF (αβ)) (p : PMF α) (b : β) :
(PMF.seq q p) b = ∑' (f : αβ) (a : α), if b = f a then q f * p a else 0
@[simp]
theorem PMF.support_seq {α : Type u_1} {β : Type u_2} (q : PMF (αβ)) (p : PMF α) :
PMF.support (PMF.seq q p) = ⋃ f ∈ ,
theorem PMF.mem_support_seq_iff {α : Type u_1} {β : Type u_2} (q : PMF (αβ)) (p : PMF α) (b : β) :
b PMF.support (PMF.seq q p) ∃ f ∈ , b
Equations
def PMF.ofFinset {α : Type u_1} (f : αENNReal) (s : ) (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) :
PMF α

Given a finset s and a function f : α → ℝ≥0∞ with sum 1 on s, such that f a = 0 for a ∉ s, we get a PMF.

Equations
Instances For
@[simp]
theorem PMF.ofFinset_apply {α : Type u_1} {f : αENNReal} {s : } (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) (a : α) :
(PMF.ofFinset f s h h') a = f a
@[simp]
theorem PMF.support_ofFinset {α : Type u_1} {f : αENNReal} {s : } (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) :
theorem PMF.mem_support_ofFinset_iff {α : Type u_1} {f : αENNReal} {s : } (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) (a : α) :
a PMF.support (PMF.ofFinset f s h h') a s f a 0
theorem PMF.ofFinset_apply_of_not_mem {α : Type u_1} {f : αENNReal} {s : } (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) {a : α} (ha : as) :
(PMF.ofFinset f s h h') a = 0
@[simp]
theorem PMF.toOuterMeasure_ofFinset_apply {α : Type u_1} {f : αENNReal} {s : } (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) (t : Set α) :
(PMF.toOuterMeasure (PMF.ofFinset f s h h')) t = ∑' (x : α),
@[simp]
theorem PMF.toMeasure_ofFinset_apply {α : Type u_1} {f : αENNReal} {s : } (h : (Finset.sum s fun (a : α) => f a) = 1) (h' : as, f a = 0) (t : Set α) [] (ht : ) :
(PMF.toMeasure (PMF.ofFinset f s h h')) t = ∑' (x : α),
def PMF.ofFintype {α : Type u_1} [] (f : αENNReal) (h : (Finset.sum Finset.univ fun (a : α) => f a) = 1) :
PMF α

Given a finite type α and a function f : α → ℝ≥0∞ with sum 1, we get a PMF.

Equations
Instances For
@[simp]
theorem PMF.ofFintype_apply {α : Type u_1} [] {f : αENNReal} (h : (Finset.sum Finset.univ fun (a : α) => f a) = 1) (a : α) :
() a = f a
@[simp]
theorem PMF.support_ofFintype {α : Type u_1} [] {f : αENNReal} (h : (Finset.sum Finset.univ fun (a : α) => f a) = 1) :
theorem PMF.mem_support_ofFintype_iff {α : Type u_1} [] {f : αENNReal} (h : (Finset.sum Finset.univ fun (a : α) => f a) = 1) (a : α) :
a PMF.support () f a 0
@[simp]
theorem PMF.toOuterMeasure_ofFintype_apply {α : Type u_1} [] {f : αENNReal} (h : (Finset.sum Finset.univ fun (a : α) => f a) = 1) (s : Set α) :
() s = ∑' (x : α),
@[simp]
theorem PMF.toMeasure_ofFintype_apply {α : Type u_1} [] {f : αENNReal} (h : (Finset.sum Finset.univ fun (a : α) => f a) = 1) (s : Set α) [] (hs : ) :
() s = ∑' (x : α),
def PMF.normalize {α : Type u_1} (f : αENNReal) (hf0 : tsum f 0) (hf : tsum f ) :
PMF α

Given an f with non-zero and non-infinite sum, get a PMF by normalizing f by its tsum.

Equations
• PMF.normalize f hf0 hf = { val := fun (a : α) => f a * (∑' (x : α), f x)⁻¹, property := }
Instances For
@[simp]
theorem PMF.normalize_apply {α : Type u_1} {f : αENNReal} (hf0 : tsum f 0) (hf : tsum f ) (a : α) :
(PMF.normalize f hf0 hf) a = f a * (∑' (x : α), f x)⁻¹
@[simp]
theorem PMF.support_normalize {α : Type u_1} {f : αENNReal} (hf0 : tsum f 0) (hf : tsum f ) :
theorem PMF.mem_support_normalize_iff {α : Type u_1} {f : αENNReal} (hf0 : tsum f 0) (hf : tsum f ) (a : α) :
a PMF.support (PMF.normalize f hf0 hf) f a 0
def PMF.filter {α : Type u_1} (p : PMF α) (s : Set α) (h : ∃ a ∈ s, a ) :
PMF α

Create new PMF by filtering on a set with non-zero measure and normalizing.

Equations
Instances For
@[simp]
theorem PMF.filter_apply {α : Type u_1} {p : PMF α} {s : Set α} (h : ∃ a ∈ s, a ) (a : α) :
(PMF.filter p s h) a = Set.indicator s (p) a * (∑' (a' : α), Set.indicator s (p) a')⁻¹
theorem PMF.filter_apply_eq_zero_of_not_mem {α : Type u_1} {p : PMF α} {s : Set α} (h : ∃ a ∈ s, a ) {a : α} (ha : as) :
(PMF.filter p s h) a = 0
theorem PMF.mem_support_filter_iff {α : Type u_1} {p : PMF α} {s : Set α} (h : ∃ a ∈ s, a ) {a : α} :
@[simp]
theorem PMF.support_filter {α : Type u_1} {p : PMF α} {s : Set α} (h : ∃ a ∈ s, a ) :
theorem PMF.filter_apply_eq_zero_iff {α : Type u_1} {p : PMF α} {s : Set α} (h : ∃ a ∈ s, a ) (a : α) :
(PMF.filter p s h) a = 0 as a
theorem PMF.filter_apply_ne_zero_iff {α : Type u_1} {p : PMF α} {s : Set α} (h : ∃ a ∈ s, a ) (a : α) :
(PMF.filter p s h) a 0 a s a
def PMF.bernoulli (p : ENNReal) (h : p 1) :

A PMF which assigns probability p to true and 1 - p to false.

Equations
Instances For
@[simp]
theorem PMF.bernoulli_apply {p : ENNReal} (h : p 1) (b : Bool) :
() b = bif b then p else 1 - p
@[simp]
theorem PMF.support_bernoulli {p : ENNReal} (h : p 1) :
PMF.support () = {b : Bool | bif b then p 0 else p 1}
theorem PMF.mem_support_bernoulli_iff {p : ENNReal} (h : p 1) (b : Bool) :
b PMF.support () bif b then p 0 else p 1