Struct rand::distributions::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::distributions::{UnitCircle, Distribution};
let circle = UnitCircle::new();
let v = circle.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. ↩
Implementations
sourceimpl UnitCircle
impl UnitCircle
sourcepub fn new() -> UnitCircle
pub fn new() -> UnitCircle
Construct a new UnitCircle
distribution.
Trait Implementations
sourceimpl Clone for UnitCircle
impl Clone for UnitCircle
sourcefn clone(&self) -> UnitCircle
fn clone(&self) -> UnitCircle
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for UnitCircle
impl Debug for UnitCircle
sourceimpl Distribution<[f64; 2]> for UnitCircle
impl Distribution<[f64; 2]> for UnitCircle
sourcefn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 2]
fn sample<R: Rng + ?Sized>(&self, rng: &mut R) -> [f64; 2]
Generate a random value of T
, using rng
as the source of randomness.
sourcefn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
fn sample_iter<'a, R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T>ⓘNotable traits for DistIter<'a, D, R, T>impl<'a, D, R, T> Iterator for DistIter<'a, D, R, T> where
D: Distribution<T>,
R: Rng + 'a, type Item = T;
where
Self: Sized,
R: Rng,
D: Distribution<T>,
R: Rng + 'a, type Item = T;
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
impl Copy for UnitCircle
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more