Documentation

Mathlib.Probability.Density

Probability density function #

This file defines the probability density function of random variables, by which we mean measurable functions taking values in a Borel space. The probability density function is defined as the Radon–Nikodym derivative of the law of X. In particular, a measurable function f is said to the probability density function of a random variable X if for all measurable sets S, ℙ(X ∈ S) = ∫ x in S, f x dx. Probability density functions are one way of describing the distribution of a random variable, and are useful for calculating probabilities and finding moments (although the latter is better achieved with moment-generating functions).

This file also defines the continuous uniform distribution and proves some properties about random variables with this distribution.

Main definitions #

Main results #

class MeasureTheory.HasPDF {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) :

A random variable X : Ω → E is said to have a probability density function (HasPDF) with respect to the measure on Ω and μ on E if the push-forward measure of along X is absolutely continuous with respect to μ and they have a Lebesgue decomposition (HaveLebesgueDecomposition).

Instances
    theorem MeasureTheory.hasPDF_iff {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X : ΩE} { : Measure Ω} {μ : Measure E} :
    theorem MeasureTheory.hasPDF_iff_of_aemeasurable {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X : ΩE} { : Measure Ω} {μ : Measure E} (hX : AEMeasurable X ) :
    theorem MeasureTheory.HasPDF.aemeasurable {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E) [HasPDF X μ] :
    instance MeasureTheory.HasPDF.haveLebesgueDecomposition {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X : ΩE} { : Measure Ω} {μ : Measure E} [HasPDF X μ] :
    theorem MeasureTheory.HasPDF.absolutelyContinuous {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X : ΩE} { : Measure Ω} {μ : Measure E} [HasPDF X μ] :
    theorem MeasureTheory.HasPDF.quasiMeasurePreserving_of_measurable {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E) [HasPDF X μ] (h : Measurable X) :

    A random variable that HasPDF is quasi-measure-preserving.

    theorem MeasureTheory.HasPDF.congr {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X Y : ΩE} { : Measure Ω} {μ : Measure E} (hXY : X =ᵐ[] Y) [hX : HasPDF X μ] :
    HasPDF Y μ
    theorem MeasureTheory.HasPDF.congr_iff {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X Y : ΩE} { : Measure Ω} {μ : Measure E} (hXY : X =ᵐ[] Y) :
    HasPDF X μ HasPDF Y μ
    theorem MeasureTheory.hasPDF_of_map_eq_withDensity {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} {X : ΩE} { : Measure Ω} {μ : Measure E} (hX : AEMeasurable X ) (f : EENNReal) (hf : AEMeasurable f μ) (h : Measure.map X = μ.withDensity f) :
    HasPDF X μ

    X HasPDF if there is a pdf f such that map X ℙ = μ.withDensity f.

    noncomputable def MeasureTheory.pdf {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) :
    EENNReal

    If X is a random variable, then pdf X ℙ μ is the Radon–Nikodym derivative of the push-forward measure of along X with respect to μ.

    Equations
    Instances For
      theorem MeasureTheory.pdf_def {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X : ΩE} :
      pdf X μ = (Measure.map X ).rnDeriv μ
      theorem MeasureTheory.pdf_of_not_aemeasurable {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X : ΩE} (hX : ¬AEMeasurable X ) :
      pdf X μ =ᵐ[μ] 0
      theorem MeasureTheory.pdf_of_not_haveLebesgueDecomposition {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X : ΩE} (h : ¬(Measure.map X ).HaveLebesgueDecomposition μ) :
      pdf X μ = 0
      theorem MeasureTheory.aemeasurable_of_pdf_ne_zero {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} (X : ΩE) (h : ¬pdf X μ =ᵐ[μ] 0) :
      theorem MeasureTheory.hasPDF_of_pdf_ne_zero {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X : ΩE} (hac : (Measure.map X ).AbsolutelyContinuous μ) (hpdf : ¬pdf X μ =ᵐ[μ] 0) :
      HasPDF X μ
      theorem MeasureTheory.measurable_pdf {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) :
      Measurable (pdf X μ)
      theorem MeasureTheory.withDensity_pdf_le_map {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {x✝ : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) :
      μ.withDensity (pdf X μ) Measure.map X
      theorem MeasureTheory.setLIntegral_pdf_le_map {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) (s : Set E) :
      ∫⁻ (x : E) in s, pdf X μ x μ (Measure.map X ) s
      theorem MeasureTheory.map_eq_withDensity_pdf {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) [hX : HasPDF X μ] :
      Measure.map X = μ.withDensity (pdf X μ)
      theorem MeasureTheory.map_eq_setLIntegral_pdf {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} (X : ΩE) ( : Measure Ω) (μ : Measure E := by volume_tac) [hX : HasPDF X μ] {s : Set E} (hs : MeasurableSet s) :
      (Measure.map X ) s = ∫⁻ (x : E) in s, pdf X μ x μ
      theorem MeasureTheory.pdf.congr {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X Y : ΩE} (hXY : X =ᵐ[] Y) :
      pdf X μ = pdf Y μ
      theorem MeasureTheory.pdf.lintegral_eq_measure_univ {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X : ΩE} [HasPDF X μ] :
      ∫⁻ (x : E), pdf X μ x μ = Set.univ
      theorem MeasureTheory.pdf.eq_of_map_eq_withDensity {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} [IsFiniteMeasure ] {X : ΩE} [HasPDF X μ] (f : EENNReal) (hmf : AEMeasurable f μ) :
      Measure.map X = μ.withDensity f pdf X μ =ᵐ[μ] f
      theorem MeasureTheory.pdf.eq_of_map_eq_withDensity' {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} [SigmaFinite μ] {X : ΩE} [HasPDF X μ] (f : EENNReal) (hmf : AEMeasurable f μ) :
      Measure.map X = μ.withDensity f pdf X μ =ᵐ[μ] f
      theorem MeasureTheory.pdf.ae_lt_top {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} [IsFiniteMeasure ] {μ : Measure E} {X : ΩE} :
      ∀ᵐ (x : E) μ, pdf X μ x <
      theorem MeasureTheory.pdf.ofReal_toReal_ae_eq {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} [IsFiniteMeasure ] {X : ΩE} :
      (fun (x : E) => ENNReal.ofReal (pdf X μ x).toReal) =ᵐ[μ] pdf X μ
      theorem MeasureTheory.pdf.lintegral_pdf_mul {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {X : ΩE} [HasPDF X μ] {f : EENNReal} (hf : AEMeasurable f μ) :
      ∫⁻ (x : E), pdf X μ x * f x μ = ∫⁻ (x : Ω), f (X x)

      The Law of the Unconscious Statistician for nonnegative random variables.

      theorem MeasureTheory.pdf.integrable_pdf_smul_iff {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {F : Type u_3} [NormedAddCommGroup F] [NormedSpace F] [IsFiniteMeasure ] {X : ΩE} [HasPDF X μ] {f : EF} (hf : AEStronglyMeasurable f μ) :
      Integrable (fun (x : E) => (pdf X μ x).toReal f x) μ Integrable (fun (x : Ω) => f (X x))
      theorem MeasureTheory.pdf.integral_pdf_smul {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {F : Type u_3} [NormedAddCommGroup F] [NormedSpace F] [IsFiniteMeasure ] {X : ΩE} [HasPDF X μ] {f : EF} (hf : AEStronglyMeasurable f μ) :
      (x : E), (pdf X μ x).toReal f x μ = (x : Ω), f (X x)

      The Law of the Unconscious Statistician: Given a random variable X and a measurable function f, f ∘ X is a random variable with expectation ∫ x, pdf X x • f x ∂μ where μ is a measure on the codomain of X.

      theorem MeasureTheory.pdf.quasiMeasurePreserving_hasPDF {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {F : Type u_3} [MeasurableSpace F] {ν : Measure F} (X : ΩE) [HasPDF X μ] {g : EF} (hg : Measure.QuasiMeasurePreserving g μ ν) (hmap : (Measure.map g (Measure.map X )).HaveLebesgueDecomposition ν) :
      HasPDF (g X) ν

      A random variable that HasPDF transformed under a QuasiMeasurePreserving map also HasPDF if (map g (map X ℙ)).HaveLebesgueDecomposition μ.

      quasiMeasurePreserving_hasPDF is more useful in the case we are working with a probability measure and a real-valued random variable.

      theorem MeasureTheory.pdf.quasiMeasurePreserving_hasPDF' {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {F : Type u_3} [MeasurableSpace F] {ν : Measure F} (X : ΩE) [HasPDF X μ] {g : EF} [SFinite ] [SigmaFinite ν] (hg : Measure.QuasiMeasurePreserving g μ ν) :
      HasPDF (g X) ν

      A real-valued random variable X HasPDF X ℙ λ (where λ is the Lebesgue measure) if and only if the push-forward measure of along X is absolutely continuous with respect to λ.

      theorem MeasureTheory.pdf.integral_mul_eq_integral {Ω : Type u_1} {m : MeasurableSpace Ω} { : Measure Ω} {X : Ω} [IsFiniteMeasure ] [HasPDF X volume] :
      (x : ), x * (pdf X volume x).toReal = (x : Ω), X x

      If X is a real-valued random variable that has pdf f, then the expectation of X equals ∫ x, x * f x ∂λ where λ is the Lebesgue measure.

      theorem MeasureTheory.pdf.hasFiniteIntegral_mul {Ω : Type u_1} {m : MeasurableSpace Ω} { : Measure Ω} {X : Ω} [IsFiniteMeasure ] {f : } {g : ENNReal} (hg : pdf X volume =ᵐ[volume] g) (hgi : ∫⁻ (x : ), f x‖ₑ * g x ) :
      HasFiniteIntegral (fun (x : ) => f x * (pdf X volume x).toReal) volume
      theorem MeasureTheory.pdf.indepFun_iff_pdf_prod_eq_pdf_mul_pdf {Ω : Type u_1} {E : Type u_2} [MeasurableSpace E] {m : MeasurableSpace Ω} { : Measure Ω} {μ : Measure E} {F : Type u_3} [MeasurableSpace F] {ν : Measure F} {X : ΩE} {Y : ΩF} [IsFiniteMeasure ] [SigmaFinite μ] [SigmaFinite ν] [HasPDF (fun (ω : Ω) => (X ω, Y ω)) (μ.prod ν)] :
      ProbabilityTheory.IndepFun X Y pdf (fun (ω : Ω) => (X ω, Y ω)) (μ.prod ν) =ᵐ[μ.prod ν] fun (z : E × F) => pdf X μ z.1 * pdf Y ν z.2

      Random variables are independent iff their joint density is a product of marginal densities.