NLA-lib Explorer

The exact mean of the squared Gram error

Library · Result group

Theorem (HasOrthonormalCols.integral_frobNorm_conjTranspose_mul_self_sub_one_sq_of_hasLaw_countSketch). The exact mean of the squared Gram error of a CountSketch for \mathbf{U} with orthonormal columns, d = \lvert r \rvert: \mathbb{E}\|(\mathbf{S}\mathbf{U})^{\mathsf{H}}\mathbf{S}\mathbf{U} - \mathbf{I}\|_{\mathsf{F}}^2 = \frac{d^2 + \|\mathbf{U}^{\mathsf{T}}\mathbf{U}\|_{\mathsf{F}}^2 - 2 \sum_i \ell_i^2}{\lvert k \rvert}\,, \ell_i the leverage scores (NLAlib.leverageScore); over \mathbb{R} the middle term is d. The AMM identity at \mathbf{A} = \mathbf{B} = \mathbf{U}. Proved without a literature source.

Headline (provisional) General form: sizes are index types

Lean statement and details
NLAlib.HasOrthonormalCols.integral_frobNorm_conjTranspose_mul_self_sub_one_sq_of_hasLaw_countSketch.{u_1,
    u_2, u_3, u_4, u_6}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} {r : Type u_6} [Fintype k] [Fintype n] [DecidableEq k] {S : Ω → Matrix k n 𝕜}
  [Fintype r] [DecidableEq r] {U : Matrix n r 𝕜} (hU : HasOrthonormalCols U)
  (hS : HasLaw S (countSketch k n) μ) :
  ∫ (ω : Ω), frobNorm ((S ω * U)ᴴ * (S ω * U) - 1) ^ 2 ∂μ =
    (↑(Fintype.card r) ^ 2 + frobNorm (Uᵀ * U) ^ 2 - 2 * ∑ i, leverageScore U i ^ 2) /
      ↑(Fintype.card k)

Full source on GitHub

Copy link

Other forms

Theorem (integral_norm_trace_mul_conjTranspose_mul_self_sub_one_sq_of_hasLaw_countSketch). The second moment of a CountSketch: for every \mathbf{M}, \mathbb{E}\lvert \operatorname{tr}(\mathbf{M}(\mathbf{S}^{\mathsf{H}}\mathbf{S} - \mathbf{I})) \rvert^2 = \frac{\|\mathbf{M}\|_{\mathsf{F}}^2 + \langle \mathbf{M}, \mathbf{M}^{\mathsf{T}} \rangle_{\mathsf{F}} - 2 \sum_i \lvert \mathbf{M}_{i,i} \rvert^2}{\lvert k \rvert}\,. [CamanoEpperlyMeyerTropp2025, Lemma B.1 and its proof] (there for self-adjoint \mathbf{M}, the uncentred moment \mathbb{E}[\operatorname{tr}(\mathbf{M}\mathbf{\Phi}\mathbf{\Phi}^{\mathsf{H}})^2], which adds (\operatorname{tr}\mathbf{M})^2; the exact expression is in the proof, the statement is the bound (\operatorname{tr}\mathbf{M})^2 + 2\|\mathbf{M}\|_{\mathsf{F}}^2/\mathbf{b} for \mathbf{b} rows). Here centred, any \mathbf{M}, any field. For a fixed hash, \operatorname{tr}(\mathbf{M}(\mathbf{S}^{\mathsf{H}}\mathbf{S} - \mathbf{I})) is a hollow Rademacher quadratic form (NLAlib.integral_norm_quadForm_sub_trace_sq at s = 1, m_4 = 1), and the collision probability NLAlib.measureReal_pi_samplingMeasure_setOf_apply_eq_apply averages the hash.

General form: sizes are index types

Lean statement and details
NLAlib.integral_norm_trace_mul_conjTranspose_mul_self_sub_one_sq_of_hasLaw_countSketch.{u_1, u_2,
    u_3, u_4}
  {Ω : Type u_1} {mΩ : MeasurableSpace Ω} {μ : Measure Ω} {𝕜 : Type u_2} [RCLike 𝕜] {k : Type u_3}
  {n : Type u_4} [Fintype k] [Fintype n] [DecidableEq k] {S : Ω → Matrix k n 𝕜} [DecidableEq n]
  (hS : HasLaw S (countSketch k n) μ) (M : Matrix n n 𝕜) :
  ∫ (ω : Ω), ‖(M * ((S ω)ᴴ * S ω - 1)).trace‖ ^ 2 ∂μ =
    (frobNorm M ^ 2 + frobInner M Mᵀ - 2 * ∑ i, ‖M i i‖ ^ 2) / ↑(Fintype.card k)

Full source on GitHub

Copy link

General form: sizes are index types. A size is carried by a finite index type: |k| is the number of elements of the index type k, and "k nonempty" means k ≥ 1.