Function malachite_q::random::random_rationals
source · pub fn random_rationals(
seed: Seed,
mean_bits_numerator: u64,
mean_bits_denominator: u64,
) -> RandomRationalsFromDoubleAndSign<RandomNaturals<GeometricRandomNaturalValues<u64>>, RandomNaturals<GeometricRandomNaturalValues<u64>>> ⓘ
Expand description
Generates random Rational
s with a specified numerator and denominator mean bit length.
The output length is infinite.
§Expected complexity per iteration
$T(n) = O(n (\log n)^2 \log\log n)$
$M(n) = O(n \log n)$
where $T$ is time, $M$ is additional memory, and $n$ is mean_bits_numerator / mean_bits_denominator
.
§Panics
Panics if mean_bits_numerator
or mean_bits_denominator
are zero or if mean_bits_numerator <= mean_bits_denominator
.
§Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::random::EXAMPLE_SEED;
use malachite_q::random::random_rationals;
assert_eq!(
prefix_to_string(random_rationals(EXAMPLE_SEED, 32, 1), 10),
"[-7301/34, -4183103/1234731190583, 54812347098686/6195807891591254727, \
812739/17841539017, -665/908, 677/1138982845180, 166/22491855393807861245619791028129, \
270142/5, 52040856788711439301087669967/15975369961878544862054, \
5718607/1953563256716085077, ...]"
)