pub fn random_unsigned_bit_chunks<T: PrimitiveUnsigned>(
    seed: Seed,
    chunk_size: u64
) -> RandomUnsignedBitChunks<T>Notable traits for RandomUnsignedBitChunks<T>impl<T: PrimitiveUnsigned> Iterator for RandomUnsignedBitChunks<T> type Item = T;
Expand description

Uniformly generates unsigned integers containing some maximum number of bits.

$$ P(x) = \begin{cases} 2^{-c} & \text{if} \quad 0 \leq x < 2^c, \\ 0 & \text{otherwise,} \end{cases} $$ where $c$ is chunk_size.

The output length is infinite.

Complexity per iteration

Constant time and additional memory.

Panics

Panics if chunk_size is zero or greater than the width of the type.

Examples

use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::random_unsigned_bit_chunks;
use malachite_base::random::EXAMPLE_SEED;

assert_eq!(
    prefix_to_string(random_unsigned_bit_chunks::<u8>(EXAMPLE_SEED, 3), 10),
    "[1, 6, 5, 7, 6, 3, 1, 2, 4, 5, ...]"
)