# mathlibdocumentation

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

• measure_theory.has_pdf : A random variable X : α → E is said to has_pdf 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 μ.with_density f.
• measure_theory.pdf : If X is a random variable that has_pdf X ℙ μ, then pdf X is the measurable function f such that the push-forward measure of ℙ along X equals μ.with_density f.
• measure_theory.pdf.uniform : 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 #

• measure_theory.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 → ℝ.
• measure_theory.pdf.integral_mul_eq_integral : A real-valued random variable X with pdf f has expectation ∫ x, x * f x dx.
• measure_theory.pdf.uniform.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]
structure measure_theory.has_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") :
Prop

A random variable X : α → E is said to has_pdf 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 μ.with_density f.

theorem measure_theory.has_pdf.measurable {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") [hX : μ] :
noncomputable def measure_theory.pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") :

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

Equations
• μ = dite μ) (λ (hX : μ), (λ (hX : ¬ μ), 0)
theorem measure_theory.pdf_undef {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} (h : ¬) :
μ = 0
theorem measure_theory.has_pdf_of_pdf_ne_zero {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} (h : μ 0) :
theorem measure_theory.pdf_eq_zero_of_not_measurable {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} (hX : ¬) :
μ = 0
theorem measure_theory.measurable_of_pdf_ne_zero {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} (X : α → E) (h : μ 0) :
theorem measure_theory.measurable_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") :
theorem measure_theory.map_eq_with_density_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") [hX : μ] :
theorem measure_theory.map_eq_set_lintegral_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") [hX : μ] {s : set E} (hs : measurable_set s) :
ℙ) s = ∫⁻ (x : E) in s, μ x μ
theorem measure_theory.pdf.lintegral_eq_measure_univ {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} [ μ] :
∫⁻ (x : E), μ x μ =
theorem measure_theory.pdf.ae_lt_top {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} :
∀ᵐ (x : E) ∂μ, μ x <
theorem measure_theory.pdf.of_real_to_real_ae_eq {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} :
(λ (x : E), ennreal.of_real μ x).to_real) =ᵐ[μ] μ
theorem measure_theory.pdf.integrable_iff_integrable_mul_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} [ μ] {f : E → } (hf : measurable f) :
measure_theory.integrable (λ (x : α), f (X x)) measure_theory.integrable (λ (x : E), (f x) * μ x).to_real) μ
theorem measure_theory.pdf.integral_fun_mul_eq_integral {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} [ μ] {f : E → } (hf : measurable f) :
(x : E), ((f x) * μ x).to_real) μ = (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 measure_theory.pdf.map_absolutely_continuous {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} [ μ] :
μ
theorem measure_theory.pdf.to_quasi_measure_preserving {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} [ μ] :

A random variable that has_pdf is quasi-measure preserving.

theorem measure_theory.pdf.have_lebesgue_decomposition_of_has_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} [hX' : μ] :
theorem measure_theory.pdf.has_pdf_iff {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} :
theorem measure_theory.pdf.has_pdf_iff_of_measurable {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {X : α → E} (hX : measurable X) :
theorem measure_theory.pdf.quasi_measure_preserving_has_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {F : Type u_3} [normed_group F] [ F] [borel_space F] {ν : measure_theory.measure F} {X : α → E} [ μ] {g : E → F} (hmap : ν) :

A random variable that has_pdf transformed under a quasi_measure_preserving map also has_pdf if (map g (map X ℙ)).have_lebesgue_decomposition μ.

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

theorem measure_theory.pdf.quasi_measure_preserving_has_pdf' {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {F : Type u_3} [normed_group F] [ F] [borel_space F] {ν : measure_theory.measure F} {X : α → E} [ μ] {g : E → F}  :
theorem measure_theory.pdf.real.has_pdf_iff_of_measurable {α : Type u_1} {m : measurable_space α} {ℙ : measure_theory.measure α} {X : α → } (hX : measurable X) :

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

theorem measure_theory.pdf.real.has_pdf_iff {α : Type u_1} {m : measurable_space α} {ℙ : measure_theory.measure α} {X : α → } :
theorem measure_theory.pdf.integral_mul_eq_integral {α : Type u_1} {m : measurable_space α} {ℙ : measure_theory.measure α} {X : α → }  :
∫ (x : ), = (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 measure_theory.pdf.has_finite_integral_mul {α : Type u_1} {m : measurable_space α} {ℙ : measure_theory.measure α} {X : α → } {f : } {g : ℝ≥0∞} (hgi : ∫⁻ (x : ), (f x∥₊) * g x ) :

Uniform Distribution

def measure_theory.pdf.is_uniform {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} (X : α → E) (support : set E) (ℙ : measure_theory.measure α) (μ : . "volume_tac") :
Prop

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.

Equations
theorem measure_theory.pdf.is_uniform.has_pdf {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {X : α → E} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {support : set E} (hns : μ support 0) (hnt : μ support ) (hu : support μ) :
theorem measure_theory.pdf.is_uniform.pdf_to_real_ae_eq {α : Type u_1} {E : Type u_2} [normed_group E] [ E] [borel_space E] {m : measurable_space α} {X : α → E} {ℙ : measure_theory.measure α} {μ : measure_theory.measure E} {s : set E} (hX : μ) :
(λ (x : E), μ x).to_real) =ᵐ[μ] λ (x : E), (s.indicator ((μ s)⁻¹ 1) x).to_real
theorem measure_theory.pdf.is_uniform.mul_pdf_integrable {α : Type u_1} {m : measurable_space α} {ℙ : measure_theory.measure α} {X : α → } {s : set } (hms : measurable_set s) (hns : 0) (hcs : is_compact s)  :
theorem measure_theory.pdf.is_uniform.integral_eq {α : Type u_1} {m : measurable_space α} {ℙ : measure_theory.measure α} {X : α → } {s : set } (hms : measurable_set s) (hns : 0)  :
(x : α), X x = * ∫ (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.