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

• MeasureTheory.HasPDF : A random variable X : Ω → E is said to HasPDF with respect to the measure ℙ on Ω and μ on E if there exists a measurable function f such that the push-forward measure of ℙ along X equals μ.withDensity f.
• MeasureTheory.pdf : If X is a random variable that HasPDF X ℙ μ, then pdf X is the measurable function f such that the push-forward measure of ℙ along X equals μ.withDensity f.
• MeasureTheory.pdf.IsUniform : A random variable X is said to follow the uniform distribution if it has a constant probability density function with a compact, non-null support.

## Main results #

• MeasureTheory.pdf.integral_fun_mul_eq_integral : Law of the unconscious statistician, i.e. if a random variable X : Ω → E has pdf f, then 𝔼(g(X)) = ∫ x, g x * f x dx for all measurable g : E → ℝ.
• MeasureTheory.pdf.integral_mul_eq_integral : A real-valued random variable X with pdf f has expectation ∫ x, x * f x dx.
• MeasureTheory.pdf.IsUniform.integral_eq : If X follows the uniform distribution with its pdf having support s, then X has expectation (λ s)⁻¹ * ∫ x in s, x dx where λ is the Lebesgue measure.

## TODOs #

Ultimately, we would also like to define characteristic functions to describe distributions as it exists for all random variables. However, to define this, we will need Fourier transforms which we currently do not have.

class MeasureTheory.HasPDF {Ω : Type u_1} {E : Type u_2} [] {m : } (X : ΩE) (ℙ : ) (μ : ) :

A random variable X : Ω → E is said to HasPDF with respect to the measure ℙ on Ω and μ on E if there exists a measurable function f such that the push-forward measure of ℙ along X equals μ.withDensity f.

Instances
theorem MeasureTheory.HasPDF.measurable {Ω : Type u_1} {E : Type u_2} [] :
∀ {x : } (X : ΩE) ( : ) (μ : ) [hX : ],
def MeasureTheory.pdf {Ω : Type u_1} {E : Type u_2} [] :
{x : } → (ΩE) → EENNReal

If X is a random variable that HasPDF X ℙ μ, then pdf X is the measurable function f such that the push-forward measure of ℙ along X equals μ.withDensity f.

Instances For
theorem MeasureTheory.pdf_undef {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} (h : ) :
= 0
theorem MeasureTheory.hasPDF_of_pdf_ne_zero {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} (h : 0) :
theorem MeasureTheory.pdf_eq_zero_of_not_measurable {Ω : Type u_1} {E : Type u_2} [] :
∀ {x : } { : } {μ : } {X : ΩE}, = 0
theorem MeasureTheory.measurable_of_pdf_ne_zero {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } (X : ΩE) (h : 0) :
theorem MeasureTheory.measurable_pdf {Ω : Type u_1} {E : Type u_2} [] {m : } (X : ΩE) (ℙ : ) (μ : ) :
theorem MeasureTheory.map_eq_withDensity_pdf {Ω : Type u_1} {E : Type u_2} [] {m : } (X : ΩE) (ℙ : ) (μ : ) [hX : ] :
theorem MeasureTheory.map_eq_set_lintegral_pdf {Ω : Type u_1} {E : Type u_2} [] {m : } (X : ΩE) (ℙ : ) (μ : ) [hX : ] {s : Set E} (hs : ) :
↑() s = ∫⁻ (x : E) in s, μ
theorem MeasureTheory.pdf.lintegral_eq_measure_univ {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} [] :
∫⁻ (x : E), μ = Set.univ
theorem MeasureTheory.pdf.ae_lt_top {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} :
∀ᵐ (x : E) ∂μ, <
theorem MeasureTheory.pdf.ofReal_toReal_ae_eq {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} :
(fun x => ) =ᶠ[]
theorem MeasureTheory.pdf.integrable_iff_integrable_mul_pdf {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} [] {f : E} (hf : ) :
theorem MeasureTheory.pdf.integral_fun_mul_eq_integral {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} [] {f : E} (hf : ) :
∫ (x : E), f x * ENNReal.toReal ()μ = ∫ (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, f x * pdf X ∂μ where μ is a measure on the codomain of X.

theorem MeasureTheory.pdf.map_absolutelyContinuous {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} [] :
theorem MeasureTheory.pdf.to_quasiMeasurePreserving {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} [] :

A random variable that HasPDF is quasi-measure preserving.

theorem MeasureTheory.pdf.haveLebesgueDecomposition_of_hasPDF {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} [hX' : ] :
theorem MeasureTheory.pdf.hasPDF_iff {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} :
theorem MeasureTheory.pdf.hasPDF_iff_of_measurable {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {X : ΩE} (hX : ) :
theorem MeasureTheory.pdf.quasiMeasurePreserving_hasPDF {Ω : Type u_1} {E : Type u_2} [] {m : } {ℙ : } {μ : } {F : Type u_3} [] {ν : } {X : ΩE} [] {g : EF} :

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} [] {m : } {ℙ : } {μ : } {F : Type u_3} [] {ν : } {X : ΩE} [] {g : EF} :
theorem Real.hasPDF_iff_of_measurable {Ω : Type u_1} {m : } {ℙ : } {X : Ω} (hX : ) :

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 Real.hasPDF_iff {Ω : Type u_1} {m : } {ℙ : } {X : Ω} :
theorem MeasureTheory.pdf.integral_mul_eq_integral {Ω : Type u_1} {m : } {ℙ : } {X : Ω} [] :
∫ (x : ), x * ENNReal.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 : } {ℙ : } {X : Ω} {f : } {g : } (hg : =ᶠ[MeasureTheory.Measure.ae MeasureTheory.volume] g) (hgi : ∫⁻ (x : ), f x‖₊ * g x ) :

Uniform Distribution

def MeasureTheory.pdf.IsUniform {Ω : Type u_1} {E : Type u_2} [] :
{x : } → (ΩE) → Set E

A random variable X has uniform distribution if it has a probability density function f with support s such that f = (μ s)⁻¹ 1ₛ a.e. where 1ₛ is the indicator function for s.

Instances For
theorem MeasureTheory.pdf.IsUniform.hasPDF {Ω : Type u_1} {E : Type u_2} [] {m : } {X : ΩE} {ℙ : } {μ : } {s : Set E} (hns : μ s 0) (hnt : μ s ) (hu : ) :
theorem MeasureTheory.pdf.IsUniform.pdf_toReal_ae_eq {Ω : Type u_1} {E : Type u_2} [] :
∀ {x : } {X : ΩE} { : } {μ : } {s : Set E}, (fun x_1 => ENNReal.toReal (MeasureTheory.pdf X x_1)) =ᶠ[] fun x => ENNReal.toReal (Set.indicator s ((μ s)⁻¹ 1) x)
theorem MeasureTheory.pdf.IsUniform.measure_preimage {Ω : Type u_1} {E : Type u_2} [] {m : } {X : ΩE} {ℙ : } {μ : } {s : Set E} (hns : μ s 0) (hnt : μ s ) (hms : ) (hu : ) {A : Set E} (hA : ) :
(X ⁻¹' A) = μ (s A) / μ s
theorem MeasureTheory.pdf.IsUniform.isProbabilityMeasure {Ω : Type u_1} {E : Type u_2} [] {m : } {X : ΩE} {ℙ : } {μ : } {s : Set E} (hns : μ s 0) (hnt : μ s ) (hms : ) (hu : ) :
theorem MeasureTheory.pdf.IsUniform.mul_pdf_integrable {Ω : Type u_1} {m : } {ℙ : } {X : Ω} {s : } (hms : ) (hns : MeasureTheory.volume s 0) (hcs : ) (huX : ) :
theorem MeasureTheory.pdf.IsUniform.integral_eq {Ω : Type u_1} {m : } {ℙ : } {X : Ω} {s : } (hms : ) (hns : MeasureTheory.volume s 0) (hnt : MeasureTheory.volume s ) (huX : ) :
∫ (x : Ω), X x = ENNReal.toReal (MeasureTheory.volume s)⁻¹ * ∫ (x : ) in s, x

A real uniform random variable X with support s has expectation (λ s)⁻¹ * ∫ x in s, x ∂λ where λ is the Lebesgue measure.