pub fn striped_random_positive_rationals(
    seed: Seed,
    mean_stripe_numerator: u64,
    mean_stripe_denominator: u64,
    mean_bits_numerator: u64,
    mean_bits_denominator: u64
) -> RandomRationalsFromSingle<StripedRandomNaturals<GeometricRandomNaturalValues<u64>>> 
Expand description

Generates striped random positive Rationals with a specified mean numerator and denominator bit length.

The actual numerator and denominator bit lengths are chosen from a geometric distribution with mean $m$, where $m$ is mean_bits_numerator / mean_bits_denominator; $m$ must be greater than

  1. A striped bit sequence with the given stripe parameter is generated and truncated at the bit lengths to produce the numerators and denominators. The highest bits are forced to be 1. Finally, the Rational is reduced.

The output length is infinite.

See StripedBitSource for information about generating striped random numbers.

§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_stripe_denominator is zero, if mean_stripe_numerator < mean_stripe_denominator, 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::striped_random_positive_rationals;

assert_eq!(
    prefix_to_string(
        striped_random_positive_rationals(EXAMPLE_SEED, 16, 1, 32, 1),
        10
    ),
    "[4, 1/268681216, 75493376/9007199120523391, 8/8796094070783, \
    8/950737950171027935941967741439, 1040391/33554432, \
    2813000899879757964630563421437095845888, 1/79164837199872, 2199023255551/16, \
    220784470296873664512/4611685966886694919, ...]"
)