Documentation

CslibFrontier.Foundations.BooleanAnalysis.Variance

Variance and covariance on the Boolean cube #

The covariance of two real functions on the cube is the sum of the products of their Fourier coefficients on the nonempty sets (BitString.expect_sub_expect_mul_sub_expect_eq_sum) O'Donnell, Proposition 1.16, as the variance is their Fourier weight on the nonempty sets (BitString.expect_sub_expect_sq_eq_sum_fourierCoeff_sq).

For a Boolean function f read as the signs F = (-1) ^ f, write dist(f, b) for the relative Hamming distance hammingDist f (fun _ => b) / 2 ^ n from f to the constant b; the constant false reads as the sign 1. The two distances sum to one (BitString.hammingDist_false_div_add_hammingDist_true_div), the mean of F is 1 - 2 dist(f, false) (BitString.expect_signVal), and the variance of F is 1 - (𝔼 F) ^ 2 = 4 dist(f, false) dist(f, true) (BitString.expect_sub_expect_sq_signVal, BitString.expect_sub_expect_sq_signVal_eq_four_mul) O'Donnell, Fact 1.14. So the variance is within a factor two of four times the distance ε to the nearer constant, 2 ε ≤ Var[F] ≤ 4 ε (BitString.two_mul_min_le_expect_sub_expect_sq_signVal, BitString.expect_sub_expect_sq_signVal_le_four_mul_min) O'Donnell, Proposition 1.15.

Main results #

References #

theorem Cslib.BitString.expect_sub_expect_mul_sub_expect_eq_sum {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f g : (ι → Bool) → ℝ) :
(Finset.univ.expect fun (x : ι → Bool) => (f x - Finset.univ.expect fun (y : ι → Bool) => f y) * (g x - Finset.univ.expect fun (y : ι → Bool) => g y)) = ∑ S : Finset ι with S ≠ ∅, fourierCoeff f S * fourierCoeff g S

The covariance is the sum of the products of the Fourier coefficients on the nonempty sets O'Donnell, Proposition 1.16.

theorem Cslib.BitString.expect_signVal {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
(Finset.univ.expect fun (x : ι → Bool) => signVal (f x)) = 1 - 2 * ↑(hammingDist f fun (x : ι → Bool) => false) / 2 ^ Fintype.card ι

The mean of a Boolean function read as signs is one minus twice its relative Hamming distance to the constant false, whose sign is 1.

theorem Cslib.BitString.hammingDist_false_div_add_hammingDist_true_div {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
↑(hammingDist f fun (x : ι → Bool) => false) / 2 ^ Fintype.card ι + ↑(hammingDist f fun (x : ι → Bool) => true) / 2 ^ Fintype.card ι = 1

The relative Hamming distances from a Boolean function to the two constants sum to one.

theorem Cslib.BitString.expect_sub_expect_sq_signVal {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
(Finset.univ.expect fun (x : ι → Bool) => (signVal (f x) - Finset.univ.expect fun (y : ι → Bool) => signVal (f y)) ^ 2) = 1 - (Finset.univ.expect fun (x : ι → Bool) => signVal (f x)) ^ 2

The variance of a Boolean function read as signs is one minus its squared mean O'Donnell, Fact 1.14.

theorem Cslib.BitString.expect_sub_expect_sq_signVal_eq_four_mul {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
(Finset.univ.expect fun (x : ι → Bool) => (signVal (f x) - Finset.univ.expect fun (y : ι → Bool) => signVal (f y)) ^ 2) = 4 * (↑(hammingDist f fun (x : ι → Bool) => false) / 2 ^ Fintype.card ι) * (↑(hammingDist f fun (x : ι → Bool) => true) / 2 ^ Fintype.card ι)

The variance of a Boolean function read as signs is four times the product of its relative Hamming distances to the two constants O'Donnell, Fact 1.14.

theorem Cslib.BitString.two_mul_min_le_expect_sub_expect_sq_signVal {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
2 * min (↑(hammingDist f fun (x : ι → Bool) => false) / 2 ^ Fintype.card ι) (↑(hammingDist f fun (x : ι → Bool) => true) / 2 ^ Fintype.card ι) ≤ Finset.univ.expect fun (x : ι → Bool) => (signVal (f x) - Finset.univ.expect fun (y : ι → Bool) => signVal (f y)) ^ 2

The variance is at least twice the distance to the nearer constant: a Boolean function read as signs has variance at least 2 ε, where ε is its relative Hamming distance to the nearer constant O'Donnell, Proposition 1.15.

theorem Cslib.BitString.expect_sub_expect_sq_signVal_le_four_mul_min {ι : Type u_1} [Fintype ι] [DecidableEq ι] (f : (ι → Bool) → Bool) :
(Finset.univ.expect fun (x : ι → Bool) => (signVal (f x) - Finset.univ.expect fun (y : ι → Bool) => signVal (f y)) ^ 2) ≤ 4 * min (↑(hammingDist f fun (x : ι → Bool) => false) / 2 ^ Fintype.card ι) (↑(hammingDist f fun (x : ι → Bool) => true) / 2 ^ Fintype.card ι)

The variance is at most four times the distance to the nearer constant: a Boolean function read as signs has variance at most 4 ε, where ε is its relative Hamming distance to the nearer constant O'Donnell, Proposition 1.15.

theorem Cslib.BitString.expect_sub_expect_sq_signVal_pos {ι : Type u_1} [Fintype ι] [DecidableEq ι] {f : (ι → Bool) → Bool} (hc : ∃ (x : ι → Bool) (y : ι → Bool), f x ≠ f y) :
0 < Finset.univ.expect fun (x : ι → Bool) => (signVal (f x) - Finset.univ.expect fun (y : ι → Bool) => signVal (f y)) ^ 2

A nonconstant Boolean function read as signs has positive variance.