pub struct UnitDisc;
Expand description
Samples uniformly from the unit disc in two dimensions.
Implemented via rejection sampling.
For a distribution that samples only from the circumference of the unit disc,
see UnitCircle
.
For a similar distribution in three dimensions, see UnitBall
.
§Plot
The following plot shows the unit disc. This distribution samples individual points from the entire area of the disc.
§Example
use rand_distr::{UnitDisc, Distribution};
let v: [f64; 2] = UnitDisc.sample(&mut rand::rng());
println!("{:?} is from the unit Disc.", v)
Trait Implementations§
Source§impl<'de> Deserialize<'de> for UnitDisc
impl<'de> Deserialize<'de> for UnitDisc
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<F: Float + SampleUniform> Distribution<[F; 2]> for UnitDisc
impl<F: Float + SampleUniform> Distribution<[F; 2]> for UnitDisc
impl Copy for UnitDisc
Auto Trait Implementations§
impl Freeze for UnitDisc
impl RefUnwindSafe for UnitDisc
impl Send for UnitDisc
impl Sync for UnitDisc
impl Unpin for UnitDisc
impl UnwindSafe for UnitDisc
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more