Probability density function #
THIS FILE IS SYNCHRONIZED WITH MATHLIB4. Any changes to this file require a corresponding PR to mathlib4.
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 variableX : Ω → E
is said tohas_pdf
with respect to the measureℙ
onΩ
andμ
onE
if there exists a measurable functionf
such that the push-forward measure ofℙ
alongX
equalsμ.with_density f
.measure_theory.pdf
: IfX
is a random variable thathas_pdf X ℙ μ
, thenpdf X
is the measurable functionf
such that the push-forward measure ofℙ
alongX
equalsμ.with_density f
.measure_theory.pdf.uniform
: A random variableX
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 variableX : Ω → E
has pdff
, then𝔼(g(X)) = ∫ x, g x * f x dx
for all measurableg : E → ℝ
.measure_theory.pdf.integral_mul_eq_integral
: A real-valued random variableX
with pdff
has expectation∫ x, x * f x dx
.measure_theory.pdf.uniform.integral_eq
: IfX
follows the uniform distribution with its pdf having supports
, thenX
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.
- pdf' : measurable X ∧ ∃ (f : E → ennreal), measurable f ∧ measure_theory.measure.map X «ℙ» = measure_theory.measure.with_density μ f
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
.
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
- measure_theory.pdf X «ℙ» μ = dite (measure_theory.has_pdf X «ℙ» μ) (λ (hX : measure_theory.has_pdf X «ℙ» μ), classical.some _) (λ (hX : ¬measure_theory.has_pdf X «ℙ» μ), 0)
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
.
A random variable that has_pdf
is quasi-measure preserving.
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.
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 λ
.
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.
Uniform Distribution
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
- measure_theory.pdf.is_uniform X support «ℙ» μ = (measure_theory.pdf X «ℙ» μ =ᵐ[μ] support.indicator ((⇑μ support)⁻¹ • 1))
A real uniform random variable X
with support s
has expectation
(λ s)⁻¹ * ∫ x in s, x ∂λ
where λ
is the Lebesgue measure.