Function malachite_base::num::random::striped::striped_random_fixed_length_bool_vecs
source · [−]pub fn striped_random_fixed_length_bool_vecs(
seed: Seed,
len: u64,
mean_stripe_numerator: u64,
mean_stripe_denominator: u64
) -> StripedRandomBoolVecs<Repeat<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 of a given length.
See here for more information.
The mean run length (before the bit sequences are truncated) is
$m$ = mean_stripe_numerator / mean_stripe_denominator
.
If len
is 0, the output consists of the empty list, repeated.
Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and $n$ is len
.
Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::striped::striped_random_fixed_length_bool_vecs;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::strings::ToBinaryString;
assert_eq!(
prefix_to_string(
striped_random_fixed_length_bool_vecs(EXAMPLE_SEED, 5, 10, 1)
.map(
|bs| bs.into_iter().map(|b| if b { '1' } else { '0' }).collect::<String>()
),
20
),
"[00000, 00000, 00000, 00000, 00011, 11000, 00000, 11111, 01111, 11111, 10000, 00011, \
00000, 00000, 11000, 00000, 11111, 00000, 00000, 11111, ...]"
);