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§
source§impl Clone for UnitCircle
impl Clone for UnitCircle
source§fn clone(&self) -> UnitCircle
fn clone(&self) -> UnitCircle
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for UnitCircle
impl Debug for UnitCircle
source§impl<F: Float + SampleUniform> Distribution<[F; 2]> for UnitCircle
impl<F: Float + SampleUniform> Distribution<[F; 2]> for UnitCircle
source§fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [F; 2]
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [F; 2]
Generate a random value of
T
, using rng
as the source of randomness.