# Documentation

Mathlib.Probability.ProbabilityMassFunction.Uniform

# Uniform Probability Mass Functions #

This file defines a number of uniform Pmf distributions from various inputs, uniformly drawing from the corresponding object.

Pmf.uniformOfFinset gives each element in the set equal probability, with 0 probability for elements not in the set.

Pmf.uniformOfFintype gives all elements equal probability, equal to the inverse of the size of the Fintype.

Pmf.ofMultiset draws randomly from the given Multiset, treating duplicate values as distinct. Each probability is given by the count of the element divided by the size of the Multiset

def Pmf.uniformOfFinset {α : Type u_1} (s : ) (hs : ) :
Pmf α

Uniform distribution taking the same non-zero probability on the nonempty finset s

Instances For
@[simp]
theorem Pmf.uniformOfFinset_apply {α : Type u_1} {s : } (hs : ) (a : α) :
↑() a = if a s then (↑())⁻¹ else 0
theorem Pmf.uniformOfFinset_apply_of_mem {α : Type u_1} {s : } (hs : ) {a : α} (ha : a s) :
↑() a = (↑())⁻¹
theorem Pmf.uniformOfFinset_apply_of_not_mem {α : Type u_1} {s : } (hs : ) {a : α} (ha : ¬a s) :
↑() a = 0
@[simp]
theorem Pmf.support_uniformOfFinset {α : Type u_1} {s : } (hs : ) :
= s
theorem Pmf.mem_support_uniformOfFinset_iff {α : Type u_1} {s : } (hs : ) (a : α) :
a a s
@[simp]
theorem Pmf.toOuterMeasure_uniformOfFinset_apply {α : Type u_1} {s : } (hs : ) (t : Set α) :
↑() t = ↑(Finset.card (Finset.filter (fun x => x t) s)) / ↑()
@[simp]
theorem Pmf.toMeasure_uniformOfFinset_apply {α : Type u_1} {s : } (hs : ) (t : Set α) [] (ht : ) :
↑() t = ↑(Finset.card (Finset.filter (fun x => x t) s)) / ↑()
def Pmf.uniformOfFintype (α : Type u_4) [] [] :
Pmf α

The uniform pmf taking the same uniform value on all of the fintype α

Instances For
@[simp]
theorem Pmf.uniformOfFintype_apply {α : Type u_1} [] [] (a : α) :
↑() a = (↑())⁻¹
@[simp]
theorem Pmf.support_uniformOfFintype (α : Type u_4) [] [] :
theorem Pmf.mem_support_uniformOfFintype {α : Type u_1} [] [] (a : α) :
theorem Pmf.toOuterMeasure_uniformOfFintype_apply {α : Type u_1} [] [] (s : Set α) :
= ↑() / ↑()
theorem Pmf.toMeasure_uniformOfFintype_apply {α : Type u_1} [] [] (s : Set α) [] (hs : ) :
s = ↑() / ↑()
def Pmf.ofMultiset {α : Type u_1} (s : ) (hs : s 0) :
Pmf α

Given a non-empty multiset s we construct the Pmf which sends a to the fraction of elements in s that are a.

Instances For
@[simp]
theorem Pmf.ofMultiset_apply {α : Type u_1} {s : } (hs : s 0) (a : α) :
↑() a = ↑() / ↑(Multiset.card s)
@[simp]
theorem Pmf.support_ofMultiset {α : Type u_1} {s : } (hs : s 0) :
Pmf.support () = ↑()
theorem Pmf.mem_support_ofMultiset_iff {α : Type u_1} {s : } (hs : s 0) (a : α) :
theorem Pmf.ofMultiset_apply_of_not_mem {α : Type u_1} {s : } (hs : s 0) {a : α} (ha : ¬a s) :
↑() a = 0
@[simp]
theorem Pmf.toOuterMeasure_ofMultiset_apply {α : Type u_1} {s : } (hs : s 0) (t : Set α) :
↑() t = (∑' (x : α), ↑(Multiset.count x (Multiset.filter (fun x => x t) s))) / ↑(Multiset.card s)
@[simp]
theorem Pmf.toMeasure_ofMultiset_apply {α : Type u_1} {s : } (hs : s 0) (t : Set α) [] (ht : ) :
↑(Pmf.toMeasure ()) t = (∑' (x : α), ↑(Multiset.count x (Multiset.filter (fun x => x t) s))) / ↑(Multiset.card s)