Documentation

CslibFrontier.Probability.BitString.Parity

Uniform sampling at a prescribed parity #

Sampling all but the final bit uniformly and completing the parity gives the uniform law on that parity fiber. The existing XOR-sampling law is moved here unchanged. The fixed-parity law also applies to binary syndrome distributions.

Main definitions #

Main results #

Completing uniform bits to parity c gives a uniform bit string of parity c.

noncomputable def Cslib.BitString.uniformParity (n : ℕ) [NeZero n] (b : Bool) :

The uniform law on n-bit words with parity b; positive dimension admits either bit.

The support is exactly the chosen parity fiber.

theorem Cslib.BitString.uniformParity_apply {n : ℕ} [NeZero n] (b : Bool) (x : BitString n) :
(uniformParity n b) x = if parity n x = b then (2 ^ (n - 1))⁻¹ else 0

Every word of the chosen parity has mass 1 / 2^(n-1), and other words have zero mass.

Parity completion supplies an exact sampler for the uniform fixed-parity law.