pub fn striped_random_integer_range_to_infinity(
seed: Seed,
a: Integer,
mean_stripe_numerator: u64,
mean_stripe_denominator: u64,
mean_bits_numerator: u64,
mean_bits_denominator: u64
) -> StripedRandomIntegerRangeToInfinity ⓘ
Expand description
Generates striped random Integer
s greater than or equal to a lower bound $a$.
The mean bit length $m$ of the Integer
s is specified; it must be greater than the bit length
of $a$. $m$ is equal to mean_bits_numerator / mean_bits_denominator
.
The actual bit length is chosen from a geometric distribution with lower bound $a$ and mean $m$. The resulting distribution has no mean or higher-order statistics (unless $a < m < a + 1$, which is not typical).
Because the Integer
s are constrained to be within a certain range, the actual mean run
length will usually not be $\mu$. Nonetheless, setting a higher $\mu$ will result in a higher
mean run length.
The output length is infinite.
See StripedBitSource
for information about generating striped random numbers.
§Expected complexity per iteration
$T(n, m) = O(n + m)$
$M(n, m) = O(n / m)$
where $T$ is time, $M$ is additional memory, $n$ is mean_precision_numerator
, and $m$ is
mean_precision_denominator
.
§Panics
Panics if mean_stripe_denominator
is zero, if mean_stripe_numerator < mean_stripe_denominator
, if mean_bits_numerator
or mean_bits_denominator
are zero, if $a >
0$ and their ratio is less than or equal to the bit length of $a$, or if they are too large and
manipulating them leads to arithmetic overflow.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::random::EXAMPLE_SEED;
use malachite_nz::integer::random::striped_random_integer_range_to_infinity;
use malachite_nz::integer::Integer;
assert_eq!(
prefix_to_string(
striped_random_integer_range_to_infinity(
EXAMPLE_SEED,
Integer::from(-1000),
20,
1,
10,
1
),
10
),
"[8192, 2, 1024, 33554400, -128, 1023, 8, 14745599, -256, -67, ...]"
)