File: Mathlib/Probability/Distributions/Uniform.lean

full_name: MeasureTheory.pdf.IsUniform
code: /-- A random variable `X` has uniform distribution on `s` if its push-forward measure is
`(μ s)⁻¹ • μ.restrict s`. -/
def IsUniform (X : Ω → E) (s : Set E) (ℙ : Measure Ω) (μ : Measure E := by volume_tac) 
goal: {x : MeasurableSpace Ω} → (Ω → E) → Set E → MeasureTheory.Measure Ω → autoParam (MeasureTheory.Measure E) _auto✝ → Prop

full_name: MeasureTheory.pdf.IsUniform.aemeasurable
code: theorem aemeasurable {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : AEMeasurable X ℙ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  μ s ≠ 0 → μ s ≠ ⊤ → MeasureTheory.pdf.IsUniform X s ℙ μ → AEMeasurable X ℙ

full_name: MeasureTheory.pdf.IsUniform.absolutelyContinuous
code: theorem absolutelyContinuous {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) : map X ℙ ≪ μ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasureTheory.pdf.IsUniform X s ℙ μ → MeasureTheory.Measure.map X ℙ ≪ μ

full_name: MeasureTheory.pdf.IsUniform.measure_preimage
code: theorem measure_preimage {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) {A : Set E} (hA : MeasurableSet A) :
    ℙ (X ⁻¹' A) = μ (s ∩ A) / μ s 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  μ s ≠ 0 →
    μ s ≠ ⊤ → MeasureTheory.pdf.IsUniform X s ℙ μ → ∀ {A : Set E}, MeasurableSet A → ℙ (X ⁻¹' A) = μ (s ∩ A) / μ s

full_name: MeasureTheory.pdf.IsUniform.isProbabilityMeasure
code: theorem isProbabilityMeasure {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : IsProbabilityMeasure ℙ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  μ s ≠ 0 → μ s ≠ ⊤ → MeasureTheory.pdf.IsUniform X s ℙ μ → MeasureTheory.IsProbabilityMeasure ℙ

full_name: MeasureTheory.pdf.IsUniform.toMeasurable_iff
code: theorem toMeasurable_iff {X : Ω → E} {s : Set E} :
    IsUniform X (toMeasurable μ s) ℙ μ ↔ IsUniform X s ℙ μ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasureTheory.pdf.IsUniform X (MeasureTheory.toMeasurable μ s) ℙ μ ↔ MeasureTheory.pdf.IsUniform X s ℙ μ

full_name: MeasureTheory.pdf.IsUniform.toMeasurable
code: protected theorem toMeasurable {X : Ω → E} {s : Set E} (hu : IsUniform X s ℙ μ) :
    IsUniform X (toMeasurable μ s) ℙ μ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasureTheory.pdf.IsUniform X s ℙ μ → MeasureTheory.pdf.IsUniform X (MeasureTheory.toMeasurable μ s) ℙ μ

full_name: MeasureTheory.pdf.IsUniform.hasPDF
code: theorem hasPDF {X : Ω → E} {s : Set E} (hns : μ s ≠ 0) (hnt : μ s ≠ ∞)
    (hu : IsUniform X s ℙ μ) : HasPDF X ℙ μ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  μ s ≠ 0 → μ s ≠ ⊤ → MeasureTheory.pdf.IsUniform X s ℙ μ → MeasureTheory.HasPDF X ℙ μ

full_name: MeasureTheory.pdf.IsUniform.pdf_eq_zero_of_measure_eq_zero_or_top
code: theorem pdf_eq_zero_of_measure_eq_zero_or_top {X : Ω → E} {s : Set E}
    (hu : IsUniform X s ℙ μ) (hμs : μ s = 0 ∨ μ s = ∞) : pdf X ℙ μ =ᵐ[μ] 0 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasureTheory.pdf.IsUniform X s ℙ μ → μ s = 0 ∨ μ s = ⊤ → MeasureTheory.pdf X ℙ μ =ᵐ[μ] 0

full_name: MeasureTheory.pdf.IsUniform.pdf_eq
code: theorem pdf_eq {X : Ω → E} {s : Set E} (hms : MeasurableSet s)
    (hu : IsUniform X s ℙ μ) : pdf X ℙ μ =ᵐ[μ] s.indicator ((μ s)⁻¹ • (1 : E → ℝ≥0∞)) 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasurableSet s → MeasureTheory.pdf.IsUniform X s ℙ μ → MeasureTheory.pdf X ℙ μ =ᵐ[μ] s.indicator ((μ s)⁻¹ • 1)

full_name: MeasureTheory.pdf.IsUniform.pdf_toReal_ae_eq
code: theorem pdf_toReal_ae_eq {X : Ω → E} {s : Set E} (hms : MeasurableSet s)
    (hX : IsUniform X s ℙ μ) :
    (fun x => (pdf X ℙ μ x).toReal) =ᵐ[μ] fun x =>
      (s.indicator ((μ s)⁻¹ • (1 : E → ℝ≥0∞)) x).toReal 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasurableSet s →
    MeasureTheory.pdf.IsUniform X s ℙ μ →
      (fun x_1 => (MeasureTheory.pdf X ℙ μ x_1).toReal) =ᵐ[μ] fun x => (s.indicator ((μ s)⁻¹ • 1) x).toReal

full_name: MeasureTheory.pdf.IsUniform.mul_pdf_integrable
code: theorem mul_pdf_integrable (hcs : IsCompact s) (huX : IsUniform X s ℙ) :
    Integrable fun x : ℝ => x * (pdf X ℙ volume x).toReal 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → ℝ} {s : Set ℝ},
  IsCompact s →
    MeasureTheory.pdf.IsUniform X s ℙ MeasureTheory.volume →
      MeasureTheory.Integrable (fun x_1 => x_1 * (MeasureTheory.pdf X ℙ MeasureTheory.volume x_1).toReal)
        MeasureTheory.volume

full_name: MeasureTheory.pdf.IsUniform.integral_eq
code: /-- A real uniform random variable `X` with support `s` has expectation
`(λ s)⁻¹ * ∫ x in s, x ∂λ` where `λ` is the Lebesgue measure. -/
theorem integral_eq (huX : IsUniform X s ℙ) :
    ∫ x, X x ∂ℙ = (volume s)⁻¹.toReal * ∫ x in s, x 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → ℝ} {s : Set ℝ},
  MeasureTheory.pdf.IsUniform X s ℙ MeasureTheory.volume →
    ∫ (x : Ω), X x ∂ℙ = (MeasureTheory.volume s)⁻¹.toReal * ∫ (x : ℝ) in s, x

full_name: MeasureTheory.pdf.IsUniform.cond
code: lemma IsUniform.cond {s : Set E} :
    IsUniform (id : E → E) s (ProbabilityTheory.cond μ s) μ 
goal: MeasureTheory.pdf.IsUniform id s (ProbabilityTheory.cond μ s) μ

full_name: MeasureTheory.pdf.uniformPDF
code: /-- The density of the uniform measure on a set with respect to itself. This allows us to abstract
away the choice of random variable and probability space. -/
def uniformPDF (s : Set E) (x : E) (μ : Measure E := by volume_tac) : ℝ≥0∞ 
goal: ℝ≥0∞

full_name: MeasureTheory.pdf.uniformPDF_eq_pdf
code: /-- Check that indeed any uniform random variable has the uniformPDF. -/
lemma uniformPDF_eq_pdf {s : Set E} (hs : MeasurableSet s) (hu : pdf.IsUniform X s ℙ μ) :
    (fun x ↦ uniformPDF s x μ) =ᵐ[μ] pdf X ℙ μ 
goal: ∀ {x : MeasurableSpace Ω} {ℙ : MeasureTheory.Measure Ω} {X : Ω → E} {s : Set E},
  MeasurableSet s →
    MeasureTheory.pdf.IsUniform X s ℙ μ → (fun x => MeasureTheory.pdf.uniformPDF s x μ) =ᵐ[μ] MeasureTheory.pdf X ℙ μ

full_name: MeasureTheory.pdf.uniformPDF_ite
code: /-- Alternative way of writing the uniformPDF. -/
lemma uniformPDF_ite {s : Set E} {x : E} :
    uniformPDF s x μ = if x ∈ s then (μ s)⁻¹ else 0 
goal: MeasureTheory.pdf.uniformPDF s x μ = if x ∈ s then (μ s)⁻¹ else 0

full_name: PMF.uniformOfFinset
code: /-- Uniform distribution taking the same non-zero probability on the nonempty finset `s` -/
def uniformOfFinset (s : Finset α) (hs : s.Nonempty) : PMF α 
goal: PMF α

full_name: PMF.uniformOfFinset_apply
code: @[simp]
theorem uniformOfFinset_apply (a : α) :
    uniformOfFinset s hs a = if a ∈ s then (s.card : ℝ≥0∞)⁻¹ else 0 
goal: (PMF.uniformOfFinset s hs) a = if a ∈ s then (↑s.card)⁻¹ else 0

full_name: PMF.uniformOfFinset_apply_of_mem
code: theorem uniformOfFinset_apply_of_mem (ha : a ∈ s) : uniformOfFinset s hs a = (s.card : ℝ≥0∞)⁻¹ 
goal: (PMF.uniformOfFinset s hs) a = (↑s.card)⁻¹

full_name: PMF.uniformOfFinset_apply_of_not_mem
code: theorem uniformOfFinset_apply_of_not_mem (ha : a ∉ s) : uniformOfFinset s hs a = 0 
goal: (PMF.uniformOfFinset s hs) a = 0

full_name: PMF.support_uniformOfFinset
code: @[simp]
theorem support_uniformOfFinset : (uniformOfFinset s hs).support = s 
goal: (PMF.uniformOfFinset s hs).support = ↑s

full_name: PMF.mem_support_uniformOfFinset_iff
code: theorem mem_support_uniformOfFinset_iff (a : α) : a ∈ (uniformOfFinset s hs).support ↔ a ∈ s 
goal: a ∈ (PMF.uniformOfFinset s hs).support ↔ a ∈ s

full_name: PMF.toOuterMeasure_uniformOfFinset_apply
code: @[simp]
theorem toOuterMeasure_uniformOfFinset_apply :
    (uniformOfFinset s hs).toOuterMeasure t = (s.filter (· ∈ t)).card / s.card 
goal: (PMF.uniformOfFinset s hs).toOuterMeasure t = ↑(Finset.filter (fun x => x ∈ t) s).card / ↑s.card

full_name: PMF.toMeasure_uniformOfFinset_apply
code: @[simp]
theorem toMeasure_uniformOfFinset_apply [MeasurableSpace α] (ht : MeasurableSet t) :
    (uniformOfFinset s hs).toMeasure t = (s.filter (· ∈ t)).card / s.card 
goal: (PMF.uniformOfFinset s hs).toMeasure t = ↑(Finset.filter (fun x => x ∈ t) s).card / ↑s.card

full_name: PMF.uniformOfFintype
code: /-- The uniform pmf taking the same uniform value on all of the fintype `α` -/
def uniformOfFintype (α : Type*) [Fintype α] [Nonempty α] : PMF α 
goal: PMF α

full_name: PMF.uniformOfFintype_apply
code: @[simp]
theorem uniformOfFintype_apply (a : α) : uniformOfFintype α a = (Fintype.card α : ℝ≥0∞)⁻¹ 
goal: (PMF.uniformOfFintype α) a = (↑(Fintype.card α))⁻¹

full_name: PMF.support_uniformOfFintype
code: @[simp]
theorem support_uniformOfFintype (α : Type*) [Fintype α] [Nonempty α] :
    (uniformOfFintype α).support = ⊤ 
goal: (PMF.uniformOfFintype α).support = ⊤

full_name: PMF.mem_support_uniformOfFintype
code: theorem mem_support_uniformOfFintype (a : α) : a ∈ (uniformOfFintype α).support 
goal: a ∈ (PMF.uniformOfFintype α).support

full_name: PMF.toOuterMeasure_uniformOfFintype_apply
code: theorem toOuterMeasure_uniformOfFintype_apply :
    (uniformOfFintype α).toOuterMeasure s = Fintype.card s / Fintype.card α 
goal: (PMF.uniformOfFintype α).toOuterMeasure s = ↑(Fintype.card ↑s) / ↑(Fintype.card α)

full_name: PMF.toMeasure_uniformOfFintype_apply
code: theorem toMeasure_uniformOfFintype_apply [MeasurableSpace α] (hs : MeasurableSet s) :
    (uniformOfFintype α).toMeasure s = Fintype.card s / Fintype.card α 
goal: (PMF.uniformOfFintype α).toMeasure s = ↑(Fintype.card ↑s) / ↑(Fintype.card α)

full_name: PMF.ofMultiset
code: /-- Given a non-empty multiset `s` we construct the `PMF` which sends `a` to the fraction of
  elements in `s` that are `a`. -/
def ofMultiset (s : Multiset α) (hs : s ≠ 0) : PMF α 
goal: PMF α

full_name: PMF.ofMultiset_apply
code: @[simp]
theorem ofMultiset_apply (a : α) : ofMultiset s hs a = s.count a / (Multiset.card s) 
goal: (PMF.ofMultiset s hs) a = ↑(Multiset.count a s) / ↑(Multiset.card s)

full_name: PMF.support_ofMultiset
code: @[simp]
theorem support_ofMultiset : (ofMultiset s hs).support = s.toFinset 
goal: (PMF.ofMultiset s hs).support = ↑s.toFinset

full_name: PMF.mem_support_ofMultiset_iff
code: theorem mem_support_ofMultiset_iff (a : α) : a ∈ (ofMultiset s hs).support ↔ a ∈ s.toFinset 
goal: a ∈ (PMF.ofMultiset s hs).support ↔ a ∈ s.toFinset

full_name: PMF.ofMultiset_apply_of_not_mem
code: theorem ofMultiset_apply_of_not_mem {a : α} (ha : a ∉ s) : ofMultiset s hs a = 0 
goal: (PMF.ofMultiset s hs) a = 0

full_name: PMF.toOuterMeasure_ofMultiset_apply
code: @[simp]
theorem toOuterMeasure_ofMultiset_apply :
    (ofMultiset s hs).toOuterMeasure t =
      (∑' x, (s.filter (· ∈ t)).count x : ℝ≥0∞) / (Multiset.card s) 
goal: (PMF.ofMultiset s hs).toOuterMeasure t =
  (∑' (x : α), ↑(Multiset.count x (Multiset.filter (fun x => x ∈ t) s))) / ↑(Multiset.card s)

full_name: PMF.toMeasure_ofMultiset_apply
code: @[simp]
theorem toMeasure_ofMultiset_apply [MeasurableSpace α] (ht : MeasurableSet t) :
    (ofMultiset s hs).toMeasure t = (∑' x, (s.filter (· ∈ t)).count x : ℝ≥0∞) / (Multiset.card s) 
goal: (PMF.ofMultiset s hs).toMeasure t =
  (∑' (x : α), ↑(Multiset.count x (Multiset.filter (fun x => x ∈ t) s))) / ↑(Multiset.card s)