pub fn uniform_random_natural_inclusive_range(
seed: Seed,
a: Natural,
b: Natural
) -> UniformRandomNaturalRange ⓘ
Expand description
Uniformly generates random Natural
s in the closed interval $[a, b]$.
$a$ must be less than or equal to $b$.
$$ P(x) = \begin{cases} \frac{1}{b-a+1} & \text{if} \quad a \leq x \leq b, \\ 0 & \text{otherwise}. \end{cases} $$
The output length is infinite.
§Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is b.significant_bits()
.
§Panics
Panics if $a > b$.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::random::EXAMPLE_SEED;
use malachite_nz::natural::random::uniform_random_natural_inclusive_range;
use malachite_nz::natural::Natural;
assert_eq!(
prefix_to_string(
uniform_random_natural_inclusive_range(
EXAMPLE_SEED,
Natural::from(10u32),
Natural::from(99u32)
),
10
),
"[97, 17, 94, 37, 56, 32, 96, 11, 17, 39, ...]"
)