pub fn uniform_random_integer_inclusive_range(
seed: Seed,
a: Integer,
b: Integer
) -> UniformRandomIntegerRange ⓘ
Expand description
Uniformly generates random Integer
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::integer::random::uniform_random_integer_inclusive_range;
use malachite_nz::integer::Integer;
assert_eq!(
prefix_to_string(
uniform_random_integer_inclusive_range(
EXAMPLE_SEED,
Integer::from(-10),
Integer::from(100)
),
10
),
"[77, 83, -3, 95, 94, 97, 74, 17, 36, 83, ...]"
)