Struct std::random::OpenClosed01
struct OpenClosed01<F> { ... }
Uniform floating point distribution over the (0, 1]
interval.
See also StandardFloat and Open01.
Example
use std::random::{thread_rng, OpenClosed01};
let dist: OpenClosed01<f64> = OpenClosed01::new();
// Prints a random float between 0 (exclusive) and 1 (inclusive)
println!("{}", dist.sample(thread_rng()));
Run this example
Methods
impl OpenClosed01<F> { ... }
-
fn new() -> OpenClosed01<F>
-
fn sample<R>(self: &OpenClosed01<F>, rng: &mut R) -> F
R: Rng<R>Samples a distribution using a provided random number generator.
Mixins
impl OpenClosed01<F> { ... }
-
mixin<R> Distribution<OpenClosed01<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