Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Variance equals the second moment minus the square of the mean

Proved
NarrowDNF.Influence.variance_eq_secondMoment

by chenghua.liu · Nov 13, 2026 · Mathlib 0df444a (Lean v4.33.1)

combinatoricsnarrow-dnf-authors-importprobabilitystoc-2027

For a finite Boolean cube, let wp(x)=∏i[p 1xi=1+(1−p)1xi=0]w_p(x)=\prod_i[p\,\mathbf1_{x_i=1}+(1-p)\mathbf1_{x_i=0}]wp​(x)=∏i​[p1xi​=1​+(1−p)1xi​=0​] and EpF=∑xwp(x)F(x)\mathbb E_pF=\sum_xw_p(x)F(x)Ep​F=∑x​wp​(x)F(x). Define Var⁡p(F)=Ep[(F−EpF)2]\operatorname{Var}_p(F)=\mathbb E_p[(F-\mathbb E_pF)^2]Varp​(F)=Ep​[(F−Ep​F)2]. For every real parameter ppp and real function FFF,

Var⁡p(F)=Ep[F2]−(EpF)2.\operatorname{Var}_p(F)=\mathbb E_p[F^2]-(\mathbb E_pF)^2.Varp​(F)=Ep​[F2]−(Ep​F)2.

For 0≤p≤10\le p\le10≤p≤1 this is the usual probability identity. The finite algebraic formulation also holds outside that interval, where the weights can be signed.

Preamble
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Pi
import Mathlib.Data.Real.Basic
import Mathlib.Logic.Equiv.Prod
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Ring
import Definitions.Def_NarrowDNF_Influence
import Definitions.Def_NarrowDNF_ProductMeasure

namespace NarrowDNF.Influence
end NarrowDNF.Influence

namespace NarrowDNF.ProductMeasure
end NarrowDNF.ProductMeasure
noncomputable section
open scoped BigOperators
open NarrowDNF
open NarrowDNF.Influence
section Cube
variable {ι : Type*} [Fintype ι] [DecidableEq ι]
Formal statement
theorem NarrowDNF.Influence.variance_eq_secondMoment (p : ℝ) (F : (ι → Bool) → ℝ) :
    variance p F = ProductMeasure.expectation p (fun x => F x ^ 2) -
      ProductMeasure.expectation p F ^ 2 := by sorry
Source
https://github.com/liuchliuch/narrow-dnf-lean/blob/eecadd6a5ea0a331d6cf9fd5cb39fc6ec854b372/NarrowDNF/Influence.lean#L80-L94

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