Function malachite_base::num::random::random_negative_signeds
source · [−]pub fn random_negative_signeds<T: PrimitiveSigned>(
seed: Seed
) -> RandomHighestBitSetValues<RandomSignedBitChunks<T>>ⓘNotable traits for RandomHighestBitSetValues<I>impl<I: Iterator> Iterator for RandomHighestBitSetValues<I> where
I::Item: PrimitiveInt, type Item = I::Item;
Expand description
Uniformly generates random negative signed integers.
$$ P(x) = \begin{cases} 2^{1-W} & \text{if} \quad x < 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_negative_signeds;
use malachite_base::random::EXAMPLE_SEED;
assert_eq!(
prefix_to_string(random_negative_signeds::<i8>(EXAMPLE_SEED), 10),
"[-15, -34, -105, -30, -58, -36, -76, -44, -95, -81, ...]"
)