pub fn random_vecs_min_length<I: Iterator>(
    seed: Seed,
    min_length: u64,
    xs_gen: &dyn Fn(Seed) -> I,
    mean_length_numerator: u64,
    mean_length_denominator: u64
) -> RandomVecs<I::Item, GeometricRandomNaturalValues<u64>, I>Notable traits for RandomVecs<T, I, J>impl<T, I: Iterator<Item = u64>, J: Iterator<Item = T>> Iterator for RandomVecs<T, I, J> type Item = Vec<T>;
Expand description

Generates random Vecs with a minimum length, using elements from an iterator.

The lengths of the Vecs are sampled from a geometric distribution with a specified mean $m$, equal to mean_length_numerator / mean_length_denominator. $m$ must be greater than min_length.

$$ P((x_i)_{i=0}^{n-1}) = \begin{cases} \frac{(m-a)^{n-a}}{(m+1-a)^{n+1-a}}\prod_{i=0}^{n-1}P(x_i) & \text{if} \quad n\geq a, \\ 0 & \text{otherwise}, \end{cases} $$ where $a$ is min_length.

xs_gen must be infinite.

Panics

Panics if mean_length_numerator or mean_length_denominator are zero, if their ratio is less than or equal to min_length, or if they are too large and manipulating them leads to arithmetic overflow.

Examples

extern crate itertools;

use itertools::Itertools;
use malachite_base::num::random::random_primitive_ints;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::vecs::random::random_vecs_min_length;

let xs = random_vecs_min_length(EXAMPLE_SEED, 2, &random_primitive_ints::<u8>, 6, 1);
let values = xs.take(20).collect_vec();
assert_eq!(
    values.iter().map(Vec::as_slice).collect_vec().as_slice(),
    &[
        &[85, 11][..],
        &[136, 200, 235, 134, 203, 223, 38, 235, 217, 177, 162, 32, 166, 234, 30, 218],
        &[90, 106, 9, 216, 204, 151],
        &[213, 97, 253, 78, 91, 39],
        &[191, 175, 170],
        &[232, 233],
        &[2, 35, 22, 217, 198, 114, 17],
        &[32, 173, 114, 65],
        &[121, 222, 173, 25, 144, 148],
        &[79, 115],
        &[52, 73, 69, 137, 91, 153, 178, 112],
        &[34, 95],
        &[106, 167],
        &[197, 130, 168, 122, 207, 172, 177, 86, 150, 221, 218, 101, 115],
        &[74, 9, 123, 109, 52, 201, 159, 247, 250, 48],
        &[133, 235],
        &[196, 40, 97, 104, 68],
        &[190, 216],
        &[7, 216, 157, 43, 43, 112, 217],
        &[24, 11, 103, 211, 84, 135, 55, 29, 206, 89, 65]
    ]
);