pub fn random_primitive_float_range<T: PrimitiveFloat>(
    seed: Seed,
    a: T,
    b: T
) -> RandomPrimitiveFloatRange<T>Notable traits for RandomPrimitiveFloatRange<T>impl<T: PrimitiveFloat> Iterator for RandomPrimitiveFloatRange<T> type Item = T;
Expand description

Generates random primitive floats in the half-open interval $[a, b)$.

Every float within the range has an equal probability of being chosen. This does not mean that the distribution approximates a uniform distribution over the reals. For example, if the range is $[0, 2)$, a float in $[1/4, 1/2)$ is as likely to be chosen as a float in $[1, 2)$, since these subranges contain an equal number of floats.

Positive and negative zero are treated as two distinct values, with negative zero being smaller than zero.

NaN is never generated.

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

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::float::NiceFloat;
use malachite_base::num::random::random_primitive_float_range;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    prefix_to_string(
        random_primitive_float_range::<f32>(EXAMPLE_SEED, -0.1, 0.1).map(NiceFloat),
        10
    ),
    "[5.664681e-11, 1.2492925e-35, 2.3242339e-29, 4.699183e-7, -2.8244436e-36, -2.264039e-37, \
    -0.0000017299129, 1.40616e-23, 2.7418007e-27, 1.5418819e-16, ...]"
);