pub fn uniform_random_integer_range(
    seed: Seed,
    a: Integer,
    b: Integer
) -> UniformRandomIntegerRange 
Expand description

Uniformly generates random Integers in the half-open interval $[a, b)$.

$a$ must be less than $b$.

$$ P(x) = \begin{cases} \frac{1}{b-a} & \text{if} \quad a \leq x < 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 \geq b$.

§Examples

use malachite_base::iterators::prefix_to_string;
use malachite_base::random::EXAMPLE_SEED;
use malachite_nz::integer::random::uniform_random_integer_range;
use malachite_nz::integer::Integer;

assert_eq!(
    prefix_to_string(
        uniform_random_integer_range(EXAMPLE_SEED, Integer::from(-10), Integer::from(100)),
        10
    ),
    "[77, 83, -3, 95, 94, 97, 74, 17, 36, 83, ...]"
)