Function malachite_base::num::random::random_natural_signeds
source · [−]pub fn random_natural_signeds<T: PrimitiveSigned>(
seed: Seed
) -> RandomSignedBitChunks<T>ⓘNotable traits for RandomSignedBitChunks<T>impl<T: RandomSignedChunkable> Iterator for RandomSignedBitChunks<T> type Item = T;
Expand description
Uniformly generates random natural (non-negative) signed integers.
$$ P(x) = \begin{cases} 2^{1-W} & \text{if} \quad x \geq 0, \\ 0 & \text{otherwise}, \end{cases} $$ where $W$ is the width of the type.
The output length is infinite.
Complexity per iteration
Constant time and additional memory.
Examples
use malachite_base::iterators::prefix_to_string;
use malachite_base::num::random::random_natural_signeds;
use malachite_base::random::EXAMPLE_SEED;
assert_eq!(
prefix_to_string(random_natural_signeds::<i8>(EXAMPLE_SEED), 10),
"[113, 94, 23, 98, 70, 92, 52, 84, 33, 47, ...]"
)