pub struct Normal<T> { /* private fields */ }Expand description
Normal (Gaussian) distribution N(μ, σ²).
§Example
use numeris::stats::{Normal, ContinuousDistribution};
let n = Normal::new(0.0_f64, 1.0).unwrap();
assert!((n.cdf(0.0) - 0.5).abs() < 1e-14);
assert!((n.quantile(0.975) - 1.96).abs() < 0.01);Implementations§
Source§impl<T: FloatScalar> Normal<T>
impl<T: FloatScalar> Normal<T>
Sourcepub fn new(mu: T, sigma: T) -> Result<Self, StatsError>
pub fn new(mu: T, sigma: T) -> Result<Self, StatsError>
Create a normal distribution with mean mu and standard deviation sigma.
Requires sigma > 0.
Source§impl<T: FloatScalar> Normal<T>
impl<T: FloatScalar> Normal<T>
Sourcepub fn sample(&self, rng: &mut Rng) -> T
pub fn sample(&self, rng: &mut Rng) -> T
Draw a random sample from this distribution.
§Example
use numeris::stats::{Normal, Rng};
let n = Normal::new(0.0_f64, 1.0).unwrap();
let mut rng = Rng::new(42);
let x = n.sample(&mut rng);
// x is drawn from N(0, 1)Sourcepub fn sample_array<const K: usize>(&self, rng: &mut Rng) -> [T; K]
pub fn sample_array<const K: usize>(&self, rng: &mut Rng) -> [T; K]
Fill a fixed-size array with independent samples.
Trait Implementations§
Source§impl<T: FloatScalar> ContinuousDistribution<T> for Normal<T>
impl<T: FloatScalar> ContinuousDistribution<T> for Normal<T>
impl<T: Copy> Copy for Normal<T>
Auto Trait Implementations§
impl<T> Freeze for Normal<T>where
T: Freeze,
impl<T> RefUnwindSafe for Normal<T>where
T: RefUnwindSafe,
impl<T> Send for Normal<T>where
T: Send,
impl<T> Sync for Normal<T>where
T: Sync,
impl<T> Unpin for Normal<T>where
T: Unpin,
impl<T> UnsafeUnpin for Normal<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Normal<T>where
T: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.