Function malachite_base::num::random::striped::striped_random_unsigneds
source · [−]pub fn striped_random_unsigneds<T: PrimitiveUnsigned>(
seed: Seed,
m_numerator: u64,
m_denominator: u64
) -> StripedRandomUnsignedBitChunks<T>ⓘNotable traits for StripedRandomUnsignedBitChunks<T>impl<T: PrimitiveUnsigned> Iterator for StripedRandomUnsignedBitChunks<T> type Item = T;
Expand description
Generates random unsigned integers from a random striped distribution.
See here for more information.
The mean run length (before the bit sequences are truncated) is
$m$ = m_numerator / m_denominator
.
The output length is infinite.
Expected complexity per iteration
$T(n) = O(n)$
$M(n) = O(n)$
where $T$ is time, $M$ is additional memory, and n
is the width of the type.
Panics
Panics if m_denominator
is zero or if m_numerator <= m_denominator.
Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::striped::striped_random_unsigneds;
use malachite_base::random::EXAMPLE_SEED;
use malachite_base::strings::ToBinaryString;
assert_eq!(
prefix_to_string(
striped_random_unsigneds::<u8>(EXAMPLE_SEED, 4, 1).map(|x| x.to_binary_string()),
10
),
"[1, 1001100, 1111111, 11000011, 0, 10000000, 1111, 1110110, 0, 11111000, ...]"
)