pub fn striped_random_floats(
seed: Seed,
mean_sci_exponent_abs_numerator: u64,
mean_sci_exponent_abs_denominator: u64,
mean_stripe_numerator: u64,
mean_stripe_denominator: u64,
mean_precision_numerator: u64,
mean_precision_denominator: u64,
mean_special_p_numerator: u64,
mean_special_p_denominator: u64,
) -> WithSpecialValues<RandomFiniteFloats<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>>>Expand description
Generates striped random finite Floats.
Special values (NaN, infinities, and zeros) are generated with the specified probability. If the
Float to be generated is finite and nonzero, then the actual precision is chosen from a
geometric distribution with mean $m$, where $m$ is mean_stripe_numerator / mean_stripe_denominator; $m$ must be greater than 0. A striped bit sequence with the given
stripe parameter is generated and truncated at the bit length. The highest bit is forced to be
1, and the Float is generated from the sequence and a random sci-exponent.
See StripedBitSource for information
about generating striped random numbers.
The output length is infinite.
§Expected complexity per iteration
$T(n, m) = O(n + m)$
$M(n, m) = O(n / m)$
where $T$ is time, $M$ is additional memory, $n$ is mean_precision_numerator, and $m$ is
mean_precision_denominator.
§Panics
Panics if mean_stripe_denominator is zero, if mean_stripe_numerator < mean_stripe_denominator, if mean_precision_numerator or mean_precision_denominator are
zero, or, if after being reduced to lowest terms, their sum is greater than or equal to
$2^{64}$.
use itertools::Itertools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_float::random::striped_random_floats;
use malachite_float::ComparableFloat;
// The number after the '#' is the precision.
assert_eq!(
striped_random_floats(EXAMPLE_SEED, 10, 1, 8, 1, 16, 1, 1, 10)
.take(50)
.map(|f| ComparableFloat(f).to_string())
.collect_vec()
.as_slice(),
&[
"7.9998#15",
"32.8#9",
"0.0",
"NaN",
"-0.00005#2",
"-5.0e2#1",
"-0.1249#10",
"-127.4999852#28",
"0.4999999#22",
"0.000243902209#28",
"-0.11719#11",
"-9.96875#23",
"-15.9844663292160586998132#75",
"Infinity",
"-0.48#5",
"-1.41e-11#5",
"-262144.0#21",
"NaN",
"8.875#12",
"-0.0",
"-0.00586#7",
"0.06#1",
"0.12695307#22",
"0.00006098#10",
"-3.073363e-8#22",
"1024.0#9",
"-3.1519e7#13",
"483.9384763#31",
"9.8324e-7#17",
"Infinity",
"-24.0#6",
"-4.0e-15#1",
"-Infinity",
"0.6083984445#31",
"-1.0e3#4",
"-0.0000153#7",
"-1.0e5#2",
"3.8297144e-6#24",
"-0.0001235#10",
"-0.0",
"-23.94#9",
"0.2#1",
"-0.007326125891#31",
"3.818422533722416844e-6#61",
"-0.00048828123727#34",
"0.0000151538#16",
"NaN",
"-0.0",
"7.0e7#1",
"20423.984375#33"
]
);