| | |
- choice(sectype, seq)
- Uniformly random secret element chosen from seq.
Given seq may contain public and/or secret elements.
If seq is empty, raises IndexError.
- choices(sectype, population, weights=None, *, cum_weights=None, k=1)
- List of k uniformly random secret elements chosen from population.
Choices are made with replacement.
Given population may contain public and/or secret elements.
If the relative weights or cumulative weights are not specified,
the choices are made with equal probability.
- getrandbits(sectype, k, bits=False)
- Uniformly random nonnegative k-bit integer value.
Return bits (instead of number) if requested.
- np_random_unit_vector(sectype, n)
- Uniformly random secret rotation of [1] + [0]*(n-1).
Expected number of secret random bits needed is ceil(log_2 n) + c,
with c a small constant, c < 3.
- randint(sectype, a, b)
- Uniformly random secret integer between a and b, incl. both endpoints.
- random(sectype)
- Uniformly random secret fixed-point number in the range [0.0, 1.0).
- random_derangement(sectype, x)
- Uniformly random derangement of given sequence x or range(x).
A derangement is a permutation without fixed points.
- random_permutation(sectype, x)
- Uniformly random permutation of given sequence x or range(x).
- random_unit_vector(sectype, n)
- Uniformly random secret rotation of [1] + [0]*(n-1).
Expected number of secret random bits needed is ceil(log_2 n) + c,
with c a small constant, c < 3.
- randrange(sectype, start, stop=None, step=1)
- Uniformly random secret integer in range(start, stop[, step]).
- sample(sectype, population, k)
- List of k uniformly random secret elements chosen from population.
Choices are made without replacement.
Given population may contain public and/or secret elements.
If the population contains repeats, then each occurrence is a
possible selection in the sample.
To choose a sample in a range of integers, use range as an argument.
This is especially fast and space efficient for sampling from a
large population, e.g.: sample(sectype, range(10000000), 60).
- shuffle(sectype, x)
- Shuffle list x secretly in-place, and return None.
Given list x may contain public or secret elements.
Elements of x are all numbers or all lists (of the same length) of numbers.
- uniform(sectype, a, b)
- Uniformly random secret fixed-point number N such that
a <= N <= b for a <= b and b <= N <= a for b < a.
|