Function malachite_base::num::random::striped::striped_random_bool_vecs_min_length
source · [−]pub fn striped_random_bool_vecs_min_length(
seed: Seed,
min_length: u64,
mean_stripe_numerator: u64,
mean_stripe_denominator: u64,
mean_length_numerator: u64,
mean_length_denominator: u64
) -> StripedRandomBoolVecs<GeometricRandomNaturalValues<u64>>ⓘNotable traits for StripedRandomBoolVecs<I>impl<I: Iterator<Item = u64>> Iterator for StripedRandomBoolVecs<I> type Item = Vec<bool>;
Expand description
Generates random striped Vec<bool>
s, with a minimum length.
See here for more information.
The lengths of the Vec
s 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
.
The mean run length (before the bit sequences are truncated) is
$m$ = mean_stripe_numerator / mean_stripe_denominator
.
Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is
mean_length_numerator / mean_length_denominator
.
Panics
Panics if mean_stripe_denominator
is zero, if
mean_stripe_numerator <= mean_stripe_denominator
, 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
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::striped::striped_random_bool_vecs_min_length;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::strings::ToBinaryString;
assert_eq!(
prefix_to_string(
striped_random_bool_vecs_min_length(EXAMPLE_SEED, 3, 10, 1, 5, 1)
.map(
|bs| bs.into_iter().map(|b| if b { '1' } else { '0' }).collect::<String>()
),
20
),
"[000000000, 0000, 00000000111, 0111, 00000000011111111, 100, 00000111, 1111111, 0001, \
111, 111111111, 00000, 000, 000, 1111, 000000, 111, 0011, 000, 1111, ...]"
);