Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Eq. (3): the stacked covariance estimator is positive semidefinite

Proved
SZFilaments.sampleCovariance_posSemidef

by LG · Sep 23, 2026 · Mathlib 0df444a (Lean v4.33.1)

linear-algebrastatistics

Equation (3) of the paper: the stacked covariance estimator is a covariance matrix.

For a stack of NNN binned profiles yky^kyk, k=1,…,Nk = 1,\dots,Nk=1,…,N, with nnn bins and mean profile yˉi=1N∑kyik\bar{y}_i = \frac1N\sum_k y^k_iyˉ​i​=N1​∑k​yik​, the estimator

Ci,j=1N∑k(yik−yˉi)(yjk−yˉj)C_{i,j} = \frac{1}{N}\sum_{k}(y^k_i-\bar{y}_i)(y^k_j-\bar{y}_j)Ci,j​=N1​k∑​(yik​−yˉ​i​)(yjk​−yˉ​j​)

is symmetric and positive semidefinite, for every sample size NNN (including the empty stack, where it is the zero matrix) and every data set. Positive semidefiniteness is what makes the χ2\chi^2χ2 of Eq. (4) a meaningful statistic and what a numerical inversion of CCC implicitly assumes; it holds identically, with no assumption on the data.

Preamble
import Definitions.Def_szStackStatistics
open Finset Matrix
Formal statement
namespace SZFilaments

theorem sampleCovariance_posSemidef {N n : ℕ} (y : Fin N → Fin n → ℝ) :
    (sampleCovariance y).PosSemidef := by sorry

end SZFilaments
Source
de Graaff A., Cai Y.-C., Heymans C., Peacock J. A., 2019, "Probing the missing baryons with the Sunyaev-Zel'dovich effect from filaments", A&A 624, A48, https://doi.org/10.1051/0004-6361/201935159, p. 3, Sect. 3.3, Eq. (3)
Read-back

What the Lean code literally says, in plain math · Aristotle (Harmonic)

Disclosure — this read-back is not blind and not independent. It was written by the same agent that drafted the Lean statement it describes, at the explicit instruction of the proposal owner, and no separate auditor saw the code. It is therefore not independent testimony: a reviewer should treat it as the drafting agent's own restatement of its own code, and should not count it as a second, blind reading of the formalization.

For arbitrary natural numbers NNN (samples) and nnn (bins) and an arbitrary real-valued array yiky^k_iyik​ with kkk ranging over an NNN-element index type and iii over an nnn-element index type, the statement asserts that the n×nn\times nn×n real matrix with entries

Ci,j  =  1N∑k(yik−yˉi)(yjk−yˉj),yˉi=1N∑kyik,C_{i,j} \;=\; \frac{1}{N}\sum_{k}\left(y^k_i - \bar{y}_i\right)\left(y^k_j - \bar{y}_j\right),\qquad \bar{y}_i = \frac{1}{N}\sum_k y^k_i,Ci,j​=N1​k∑​(yik​−yˉ​i​)(yjk​−yˉ​j​),yˉ​i​=N1​k∑​yik​,

is positive semidefinite: it is symmetric (self-adjoint over the reals) and its quadratic form xTCxx^{T} C xxTCx is nonnegative for every real vector xxx.

There are no hypotheses at all: NNN may be 000 (all sums empty, the divisions are by zero, and the matrix is the zero matrix, which is positive semidefinite), nnn may be 000 (the empty matrix), and the data are arbitrary reals. The divisor is NNN and not N−1N-1N−1. The claim is about this specific estimator only; it says nothing about unbiasedness, about the covariance of the mean, or about any probabilistic model generating the data.

Human review
  • Endorsed by Shuze Chen · Sep 24, 2026

    Confirmed by the moderator at approval.

  • Endorsed by LG · Sep 24, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me