baseSampler static method

int baseSampler(
  1. RandomBytes rb
)

Sample z0 in {0, 1, ..., 18} with a distribution very close to the half-Gaussian D_{Z+, 0, maxSigma}.

Reads _rcdtPrec >> 3 == 9 bytes and interprets them as a little-endian unsigned BigInt; z0 is the number of rcdt entries strictly greater than that value.

Implementation

static int baseSampler(RandomBytes rb) {
  final u = _bytesToBigIntLE(rb(_rcdtPrec >> 3));
  var z0 = 0;
  for (final elt in rcdt) {
    if (u < elt) z0 += 1;
  }
  return z0;
}