Documentation

TauCeti.Analysis.Matrix.SampleSecondMoment

The empirical second-moment matrix #

For a finite sample v : ฮน โ†’ n โ†’ ๐•œ of vectors over โ„ or โ„‚, the uncentered empirical second-moment matrix is

Mฬ‚ = rโปยน โˆ‘แตข vแตข vแตขแดด, with entries Mฬ‚โ‚–โ‚— = rโปยน โˆ‘แตข vแตขโ‚– conj (vแตขโ‚—),

where r = card ฮน. It is the mean (TauCeti.finiteMean) of the rank-one matrices vแตข vแตขแดด, so it is Hermitian and positive semidefinite. Evaluated on random samples it is the natural estimator of a population second-moment matrix E[V Vแดด]; each of its entries is a sample mean of products of coordinates, which is what makes the second-moment bounds for sample means apply to it entry by entry.

Main declarations #

References #

noncomputable def TauCeti.sampleSecondMoment {๐•œ : Type u_1} {ฮน : Type u_2} {n : Type u_3} [RCLike ๐•œ] [Fintype ฮน] (v : ฮน โ†’ n โ†’ ๐•œ) :
Matrix n n ๐•œ

The uncentered empirical second-moment matrix rโปยน โˆ‘แตข vแตข vแตขแดด of a finite sample v : ฮน โ†’ n โ†’ ๐•œ, where r = card ฮน: the mean of the rank-one matrices vแตข vแตขแดด. The empty sample has second-moment matrix 0.

Instances For
    theorem TauCeti.sampleSecondMoment_def {๐•œ : Type u_1} {ฮน : Type u_2} {n : Type u_3} [RCLike ๐•œ] [Fintype ฮน] (v : ฮน โ†’ n โ†’ ๐•œ) :
    sampleSecondMoment v = finiteMean ๐•œ fun (i : ฮน) => Matrix.vecMulVec (v i) (star (v i))
    @[simp]
    theorem TauCeti.sampleSecondMoment_apply {๐•œ : Type u_1} {ฮน : Type u_2} {n : Type u_3} [RCLike ๐•œ] [Fintype ฮน] (v : ฮน โ†’ n โ†’ ๐•œ) (k l : n) :
    sampleSecondMoment v k l = finiteMean ๐•œ fun (i : ฮน) => v i k * star (v i l)

    The (k, l) entry of the empirical second-moment matrix is the sample mean of the products vแตขโ‚– conj (vแตขโ‚—).

    theorem TauCeti.isHermitian_sampleSecondMoment {๐•œ : Type u_1} {ฮน : Type u_2} {n : Type u_3} [RCLike ๐•œ] [Fintype ฮน] (v : ฮน โ†’ n โ†’ ๐•œ) :

    The empirical second-moment matrix is Hermitian.

    theorem TauCeti.posSemidef_sampleSecondMoment {๐•œ : Type u_1} {ฮน : Type u_2} {n : Type u_3} [RCLike ๐•œ] [Fintype ฮน] [Finite n] (v : ฮน โ†’ n โ†’ ๐•œ) :

    The empirical second-moment matrix is positive semidefinite.

    noncomputable def Matrix.sampleCovariance {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] (X : Matrix p n ๐•œ) :
    Matrix p p ๐•œ

    The sample covariance matrix X Xแดด / n of a p ร— n data matrix X, with the n columns as samples. When n is empty it is 0.

    Instances For
      theorem Matrix.sampleCovariance_def {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] (X : Matrix p n ๐•œ) :
      @[simp]
      theorem Matrix.sampleCovariance_apply {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] (X : Matrix p n ๐•œ) (i j : p) :
      X.sampleCovariance i j = (1 / โ†‘(Fintype.card n)) โ€ข โˆ‘ k : n, X i k * star (X j k)

      The (i, j) entry of the sample covariance matrix.

      theorem Matrix.re_trace_sampleCovariance {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] [Fintype p] (X : Matrix p n ๐•œ) :
      RCLike.re X.sampleCovariance.trace = 1 / โ†‘(Fintype.card n) * โˆ‘ i : p, โˆ‘ j : n, โ€–X i jโ€– ^ 2

      The real trace of a sample covariance matrix is the column-normalized sum of squared entry norms. This holds for empty index types, with the usual zero conventions.

      theorem Matrix.sampleCovariance_eq_sampleSecondMoment {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] (X : Matrix p n ๐•œ) :
      X.sampleCovariance = TauCeti.sampleSecondMoment fun (k : n) (i : p) => X i k

      The sample covariance matrix of X is the empirical second-moment matrix of its columns.

      theorem Matrix.isHermitian_sampleCovariance {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] (X : Matrix p n ๐•œ) :

      The sample covariance matrix is Hermitian.

      theorem Matrix.posSemidef_sampleCovariance {๐•œ : Type u_1} [RCLike ๐•œ] {p : Type u_2} {n : Type u_3} [Fintype n] [Finite p] (X : Matrix p n ๐•œ) :

      The sample covariance matrix is positive semidefinite.