pub fn special_random_primitive_floats<T: PrimitiveFloat>(
    seed: Seed,
    mean_sci_exponent_numerator: u64,
    mean_sci_exponent_denominator: u64,
    mean_precision_numerator: u64,
    mean_precision_denominator: u64,
    mean_special_p_numerator: u64,
    mean_special_p_denominator: u64
) -> WithSpecialValues<SpecialRandomNonzeroFiniteFloats<T>>Notable traits for WithSpecialValues<I>impl<I: Iterator> Iterator for WithSpecialValues<I> where
    I::Item: Clone
type Item = I::Item;
Expand description

Generates primitive floats.

Simpler floats (those with a lower absolute sci-exponent or precision) are more likely to be chosen. You can specify the numerator and denominator of the probability that zero, infinity, or NaN will be generated. You can also specify the mean absolute sci-exponent and precision by passing the numerators and denominators of their means of the finite floats.

But note that the specified means are only approximate, since the distributions we are sampling are truncated geometric, and their exact means are somewhat annoying to deal with. The practical implications are that

  • The actual means are slightly lower than the specified means.
  • However, increasing the specified means increases the actual means, so this still works as a mechanism for controlling the sci-exponent and precision.
  • The specified sci-exponent mean must be greater than 0 and the precision mean greater than 2, but they may be as high as you like.

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::basic::floats::PrimitiveFloat;
use malachite_base::num::float::NiceFloat;
use malachite_base::num::random::special_random_primitive_floats;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    prefix_to_string(
        special_random_primitive_floats::<f32>(EXAMPLE_SEED, 10, 1, 10, 1, 1, 10)
                .map(NiceFloat),
        20
    ),
    "[0.65625, 0.0000014255784, 0.013183594, Infinity, -0.8125, -74240.0, -0.0078125, \
    -0.03060913, 3.331552, 4.75, -0.000038146973, -0.3125, -27136.0, Infinity, -59392.0, \
    -1.75, -41.1875, Infinity, 0.30940247, -0.0009765625, ...]"
);