Binary samples as canonical residues #
sampleBinaryNat w reads w fair bits as a natural number below 2 ^ w. These are exactly the
canonical representatives ZMod.val of the residues modulo 2 ^ w, so the sampler draws the
canonical representative of a uniform residue. Repeating it lists the representatives of a uniform
residue vector, in coordinate order, and repeating those runs lists the rows of a uniform residue
matrix. Every count and the width may be zero; at width zero every sample is 0, the only
representative modulo 1.
For a positive modulus q, reducing each of count samples modulo q gives a vector
within statistical distance count * (q / 2 ^ w) of uniform.
Main results #
Cslib.ProbComp.eval_sampleBinaryNat_eq_map_val: one sample is the representative of a uniform residue modulo2 ^ w.Cslib.ProbComp.eval_replicate_sampleBinaryNat:countsamples list the representatives of a uniform residue vector.Cslib.ProbComp.eval_replicate_replicate_sampleBinaryNat:rowslists ofcolssamples list, row by row, the representatives of a uniformrows × colsresidue matrix.Cslib.ProbComp.dist_replicateFin_sampleModNat_le,Cslib.ProbComp.closeTo_replicate_sampleModIndex_precision: approximating a uniform residue vector and its canonical representatives from a bounded fair-bit tape.
An unsigned w-bit sample is the canonical representative of a uniform residue modulo
2 ^ w.
count independent unsigned w-bit samples list the canonical representatives of a uniform
residue vector modulo 2 ^ w.
rows independent lists of cols unsigned w-bit samples list, row by row, the canonical
representatives of a uniform rows × cols residue matrix modulo 2 ^ w.
A bounded modular sample is already the canonical representative of its residue.
Reducing independent binary samples modulo q approximates a uniform residue vector.
The statistical error is at most the sum of the one-coordinate errors.
The list of unary residues produced by independent bounded samplers approximates the
canonical representatives of a uniform vector, with error at most count * q / 2 ^ width on
every event.
Every supported list of modular samples consists of the canonical representatives of a residue vector of the requested dimension.
Using the bit lengths of the count and modulus plus precision bits per sample gives
statistical error at most 2 ^ (-precision) for the whole list.