Skip to main content

random_integer_vectors

Function random_integer_vectors 

Source
pub fn random_integer_vectors(
    seed: Seed,
    mean_bits_numerator: u64,
    mean_bits_denominator: u64,
    mean_length_numerator: u64,
    mean_length_denominator: u64,
) -> RandomIntegerVectors<RandomVecs<Integer, GeometricRandomNaturalValues<u64>, RandomVectorElements>> ⓘ
Expand description

Generates random IntegerVectors.

The elements are sampled from random_integers, with a mean bit count of mean_bits_numerator / mean_bits_denominator. The dimensions are sampled from a geometric distribution with mean mean_length_numerator / mean_length_denominator, so the 0-dimensional vector is generated with the probability that that distribution gives to 0.

The output length is infinite.

§Worst-case complexity per iteration

$T(i) = O(nb)$

$M(i) = O(nb)$

where $T$ is time, $M$ is additional memory, $i$ is the iteration number, $n$ is the dimension of the $i$th output, and $b$ is mean_bits_numerator / mean_bits_denominator.

§Panics

Panics if mean_bits_numerator or mean_bits_denominator are zero, if mean_length_numerator or mean_length_denominator are zero, or if either ratio, after being reduced to lowest terms, has a numerator and denominator whose sum is greater than or equal to $2^{64}$.

§Examples

use malachite_base::iterators::prefix_to_string;
use malachite_base::random::EXAMPLE_SEED;
use malachite_nz::integer_vector::random::random_integer_vectors;

assert_eq!(
    prefix_to_string(random_integer_vectors(EXAMPLE_SEED, 4, 1, 2, 1), 5),
    "[(-497, -1, 1, 19, 799, 799), (-1), (66, -10721, 334, 59, -119, -5, 0, -131), (-1), \
    (0, 7, -1, 10, 11, -37408, 0, -1, -903, 28, 0, 0, -6, 2), ...]"
);