Function malachite_base::num::random::random_positive_primitive_floats
source · [−]pub fn random_positive_primitive_floats<T: PrimitiveFloat>(
seed: Seed
) -> RandomPrimitiveFloatInclusiveRange<T>ⓘNotable traits for RandomPrimitiveFloatInclusiveRange<T>impl<T: PrimitiveFloat> Iterator for RandomPrimitiveFloatInclusiveRange<T> type Item = T;
Expand description
Generates positive primitive floats.
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, 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 zero is generated; negative zero is not. NaN
is not generated either.
The output length is infinite.
Expected complexity per iteration
Constant time and additional memory.
Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::float::NiceFloat;
use malachite_base::num::random::random_positive_primitive_floats;
use malachite_base::random::EXAMPLE_SEED;
assert_eq!(
prefix_to_string(random_positive_primitive_floats::<f32>(EXAMPLE_SEED).map(NiceFloat), 10),
"[9.5715654e26, 209.6476, 386935780.0, 7.965817e30, 0.00021030706, 0.0027270128, \
3.4398167e-34, 2.3397111e14, 44567765000.0, 2.3479653e21, ...]"
);