Documentation

TauCeti.Probability.Moments.Covariance

Covariances and covariance matrices #

Covariance is unchanged by almost-everywhere changes to either observable. This file also packages the coordinate covariances of a measure on a finite-dimensional Euclidean space as a matrix and connects that matrix to Mathlib's basis-free covarianceBilin.

The MemLp id 2 μ hypothesis in the comparison theorem is essential. Mathlib deliberately sets covarianceBilin μ to zero when this hypothesis fails, whereas its scalar covariance is totalized coordinate by coordinate.

Main results #

References #

theorem TauCeti.covariance_congr_ae {Ω : Type u_1} [MeasurableSpace Ω] {μ : MeasureTheory.Measure Ω} {X X' Y Y' : Ω → ℝ} (hX : X =ᵐ[μ] X') (hY : Y =ᵐ[μ] Y') :

Covariance is unchanged by almost-everywhere changes to either observable.

noncomputable def TauCeti.covMatrix {ι : Type u_1} (μ : MeasureTheory.Measure (EuclideanSpace ℝ ι)) :
Matrix ι ι ℝ

The covariance matrix of a measure on a finite-dimensional Euclidean space. Its (i, j) entry is the scalar covariance of the ith and jth coordinate projections.

Instances For
    @[simp]
    theorem TauCeti.covMatrix_apply {ι : Type u_1} (μ : MeasureTheory.Measure (EuclideanSpace ℝ ι)) (i j : ι) :
    covMatrix μ i j = ProbabilityTheory.covariance (fun (z : EuclideanSpace ℝ ι) => z.ofLp i) (fun (z : EuclideanSpace ℝ ι) => z.ofLp j) μ

    An entry of covMatrix is the covariance of the corresponding coordinate projections.

    theorem TauCeti.covMatrix_apply_comm {ι : Type u_1} (μ : MeasureTheory.Measure (EuclideanSpace ℝ ι)) (i j : ι) :
    covMatrix μ i j = covMatrix μ j i

    Covariance matrices are symmetric.

    A covariance matrix is Hermitian (equivalently, symmetric over ℝ).

    For a finite measure with finite second moment, the entrywise covariance matrix represents Mathlib's basis-free covariance bilinear form.

    The covariance matrix of a finite measure with finite second moment is positive semidefinite.

    The mean of the quadratic form of a matrix B on the centred variable of a Euclidean-valued probability measure with finite second moment is the trace of B times the covariance matrix.

    The mean of the quadratic form of a matrix B on the centred variable of a square-integrable Euclidean-valued random vector X is the trace of B times the covariance matrix of the law of X.

    The second moment of a Euclidean-valued probability measure about a point c is the squared distance from its mean to c plus the trace of its covariance matrix.

    Covariance of an isotropic law. A finite measure on a finite-dimensional real inner product space that is invariant under every linear isometry has covariance a multiple of the inner product, the multiple being the second moment divided by the dimension. No moment hypothesis is needed: without a finite second moment both sides vanish.