struct Open01<F> { ... }
Uniform floating point distribution over the (0, 1)
interval.
See also StandardFloat and OpenClosed01.
Example
use std::random::{thread_rng, Open01};
let dist: Open01<f64> = Open01::new();
// Prints a random float between 0 and 1 exclusive
println!("{}", dist.sample(thread_rng()));
Run this example
Methods
impl Open01<F> { ... }
-
fn new() -> Open01<F>
-
Samples a distribution using a provided random number generator.
Mixins
impl Open01<F> { ... }
-
mixin<R> Distribution<Open01<F>, F, R>
R: Rng<R> -
fn sample_iter(self: &Self, rng: &mut R) -> DistIterator<Self, T, R>
Raturns an iterator producing an infinite stream of values sampled from the distribution.
Example
use std::random::{thread_rng, UniformInteger}; let dist = UniformInteger::new(0..=5); // Prints 10 random numbers between 0 and 5 inclusive for i in dist.sample_iter(thread_rng()).take(10) { println!("{}", i); }
Run this example