pub fn exponential_random_floats(
seed: Seed,
prec: u64,
rm: RoundingMode,
) -> ExponentialRandomFloats<RandomPrimitiveInts<u64>> ⓘExpand description
Generates random Floats sampled, with rounding, from the exponential distribution with mean
1.
The result is a correctly-rounded sample: each output is a precision-prec Float, and the
probability of any output equals the probability that an exponentially-distributed real number
rounds to it under rm. The sampler is von Neumann’s rejection algorithm as used by
mpfr_erandom, which draws no transcendental function evaluations; the number of random bits
consumed is finite with probability 1 but not bounded. Every output is positive: a zero would
require underflow, whose probability is on the order of $2^{-2^{30}}$. The result is never
exact, so Exact is not a valid rounding mode.
The output length is infinite.
§Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is prec.
§Panics
Panics if prec is zero or if rm is Exact.
§Examples
use itertools::Itertools;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::rounding_modes::RoundingMode::*;
use malachite_float::float::random::exponential_random_floats;
use malachite_float::ComparableFloat;
// The number after the '#' is the precision.
assert_eq!(
exponential_random_floats(EXAMPLE_SEED, 10, Nearest)
.take(20)
.map(|f| ComparableFloat(f).to_string())
.collect_vec()
.as_slice(),
&[
"0.63184#10",
"1.4648#10",
"0.96582#10",
"2.6836#10",
"3.6719#10",
"2.5703#10",
"0.097046#10",
"1.6602#10",
"0.69629#10",
"0.052429#10",
"0.58398#10",
"0.23486#10",
"0.88965#10",
"2.1992#10",
"1.7480#10",
"0.16748#10",
"0.35693#10",
"1.0996#10",
"0.44238#10",
"0.51172#10"
]
);