Documentation

TauCeti.Probability.Quantile

The quantile function of a real law #

The quantile function, or generalized inverse cumulative distribution function, of a measure μ on ℝ sends a level t to the least point at which ProbabilityTheory.cdf μ reaches t:

μ.quantile t = sInf {x | t ≤ cdf μ x}.

Because cdf μ is monotone and right continuous with limits 0 at -∞ and 1 at +∞, that infimum is attained for every level t strictly between 0 and 1, and the defining set is exactly the closed ray to the right of the quantile. The quantile is therefore characterized by the Galois property μ.quantile t ≤ x ↔ t ≤ cdf μ x. At levels t ≤ 0 and 1 < t the infimum ranges over all of ℝ or over the empty set, so the value there is the junk value 0. The endpoint level t = 1 is not junk: the quantile there is the least point of full cumulative mass when such a point exists (for instance (dirac a).quantile 1 = a), and 0 when the law has unbounded support to the right. The inverse characterizations below use levels in Ioo 0 1, which is also the interval the uniform law is taken on.

The main result is inverse transform sampling: for a probability measure μ the quantile function pushes the uniform law on the open unit interval forward to μ. It presents every real law as the law of one explicit measurable function of a single uniform variable, and it is what makes the monotone rearrangement of two real laws a transport plan between them.

Main definitions #

Main statements #

References #

Adapted from #

The probability integral transform cdf_map_eq_volume_restrict, the inverse laws cdf_quantile_ae and quantile_cdf_ae, the inverse transform sampling theorem map_quantile_volume_Ioo and the resulting realMod0MeasureIso instance are adapted from Cameron Freer's independent implementation in Graphon/MeasureIso.lean at commit 9f7be59fa754d260a544b4cfd83d6a5b94f7552e: https://github.com/cameronfreer/graphon/commit/9f7be59fa754d260a544b4cfd83d6a5b94f7552e, where they appear as cdf_map_eq_volume_restrict, cdf_cdfQuantile_ae, cdfQuantile_cdf_ae, map_cdfQuantile_volume_restrict and realMod0MeasureIso, with the generalized inverse called cdfQuantile rather than quantile; the graphon-specific packaging was removed. The original work is copyright Cameron Freer and licensed under Apache 2.0.

The measure-preserving equivalence that this file realizes on the real line is the classical transport of an atomless standard-Borel space to the unit interval, proved as Theorem A.7 in S. Janson, Graphons, cut norm and distance, couplings and rearrangements, Arkiv för Matematik 52 (2014); see also TauCeti.MeasureTheory.Measure.exists_mpModNull_equiv_unitInterval in TauCeti.MeasureTheory.Measure.AtomlessStandardBorel, which composes it with TauCeti.embeddingRealMod0MeasureIso.

noncomputable def MeasureTheory.Measure.quantile (μ : Measure ℝ) (t : ℝ) :

The quantile function of a measure on ℝ: the least point at which its cumulative distribution function reaches the level t.

This is the honest generalized inverse of ProbabilityTheory.cdf μ for t in Set.Ioo 0 1. At levels t ≤ 0 and 1 < t the defining infimum ranges over all of ℝ or over the empty set, and the value is the junk value 0 (quantile_of_nonpos, quantile_of_one_lt). At the endpoint level t = 1 the value is the least point where the cumulative distribution function reaches 1 if there is one, and 0 otherwise.

Equations
Instances For

    The quantile function is the infimum of the points at which the cumulative distribution function reaches the level. The definition's body is not exposed, so this is the lemma downstream modules should rewrite with.

    Below the level 1 some point has cumulative mass at least the level, because the cumulative distribution function tends to 1 at +∞.

    Above the level 0 the points whose cumulative mass reaches the level are bounded below, because the cumulative distribution function tends to 0 at -∞.

    @[simp]
    theorem MeasureTheory.Measure.quantile_of_nonpos {t : ℝ} (μ : Measure ℝ) (ht : t ≤ 0) :
    μ.quantile t = 0

    At a nonpositive level the quantile function takes the junk value 0: every point has cumulative mass at least the level.

    @[simp]
    theorem MeasureTheory.Measure.quantile_of_one_lt {t : ℝ} (μ : Measure ℝ) (ht : 1 < t) :
    μ.quantile t = 0

    Above the level 1 the quantile function takes the junk value 0: no point has cumulative mass that large.

    theorem MeasureTheory.Measure.le_cdf_quantile {t : ℝ} (μ : Measure ℝ) (h1 : t < 1) :

    The cumulative distribution function at the quantile reaches every level strictly below 1.

    @[simp]
    theorem MeasureTheory.Measure.quantile_le_iff {t x : ℝ} (μ : Measure ℝ) (h0 : 0 < t) (h1 : t < 1) :

    The Galois characterization of the quantile. For a level strictly between 0 and 1, the quantile lies below a point exactly when the cumulative distribution function at that point reaches the level.

    theorem MeasureTheory.Measure.setOf_le_cdf_eq_Ici {t : ℝ} (μ : Measure ℝ) (h0 : 0 < t) (h1 : t < 1) :

    The set of points whose cumulative mass reaches a level strictly between 0 and 1 is the closed ray to the right of the quantile at that level.

    @[simp]
    theorem MeasureTheory.Measure.lt_quantile_iff {t x : ℝ} (μ : Measure ℝ) (h0 : 0 < t) (h1 : t < 1) :
    x < μ.quantile t ↔ ↑(ProbabilityTheory.cdf μ) x < t

    A point lies strictly below the quantile at a level exactly when its cumulative mass has not yet reached that level.

    The quantile function is monotone on the levels where it is the honest generalized inverse.

    The quantile function is measurable.

    Inverse transform sampling. The quantile function of a probability law on ℝ pushes the uniform law on the open unit interval forward to that law.

    Inverse transform sampling, as a measure-preserving map from the uniform law on the open unit interval.

    @[simp]

    The probability integral transform. The CDF of an atomless probability measure on ℝ pushes the measure forward to Lebesgue measure restricted to [0, 1].

    On the closed unit interval, the CDF and quantile are inverse almost everywhere.

    The quantile of the CDF is the identity almost everywhere, for every real probability measure. The cumulative distribution function of a law with atoms has plateaus, but the part of a plateau strictly to the right of a point whose cumulative mass is below 1 is null, so almost every point is the least point reaching its own level.

    The CDF/quantile transport of an atomless real law. The cumulative distribution function and the quantile function of an atomless probability measure ν on ℝ push ν and Lebesgue measure restricted to [0, 1] forward onto one another, and are mutually inverse almost everywhere; together they are a mod-zero isomorphism between ν and the unit interval.

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For