Struct rand_distr::UnitCircle
source · [−]pub struct UnitCircle;
Expand description
Samples uniformly from the edge of the unit circle in two dimensions.
Implemented via a method by von Neumann1.
Example
use rand_distr::{UnitCircle, Distribution};
let v: [f64; 2] = UnitCircle.sample(&mut rand::thread_rng());
println!("{:?} is from the unit circle.", v)
von Neumann, J. (1951) Various Techniques Used in Connection with Random Digits. NBS Appl. Math. Ser., No. 12. Washington, DC: U.S. Government Printing Office, pp. 36-38. ↩
Trait Implementations
Generate a random value of T
, using rng
as the source of randomness.
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T>ⓘ where
R: Rng,
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
Auto Trait Implementations
impl RefUnwindSafe for UnitCircle
impl Send for UnitCircle
impl Sync for UnitCircle
impl Unpin for UnitCircle
impl UnwindSafe for UnitCircle
Blanket Implementations
Mutably borrows from an owned value. Read more