pub fn random_signed_range<T: PrimitiveSigned>(
    seed: Seed,
    a: T,
    b: T
) -> RandomSignedRange<T>
Expand description

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

$a$ must be less than $b$. This function cannot create a range that includes T::MAX; for that, use random_signed_inclusive_range.

$$ 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

Constant time and additional memory.

Panics

Panics if $a \geq b$.

Examples

use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::random_signed_range;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    prefix_to_string(random_signed_range::<i8>(EXAMPLE_SEED, -100, 100), 10),
    "[13, -31, 8, 68, 61, -13, -68, 10, -17, 88, ...]"
)