pub struct SkewNormal<F>{ /* private fields */ }Expand description
The skew normal distribution SN(ξ, ω, α).
The skew normal distribution is a generalization of the
Normal distribution to allow for non-zero skewness.
It has location parameter ξ (xi), scale parameter ω (omega),
and shape parameter α (alpha).
The ξ and ω parameters correspond to the mean μ and standard
deviation σ of the normal distribution, respectively.
The α parameter controls the skewness.
§Density function
It has the density function, for scale > 0,
f(x) = 2 / scale * phi((x - location) / scale) * Phi(alpha * (x - location) / scale)
where phi and Phi are the density and distribution of a standard normal variable.
§Plot
The following plot shows the skew normal distribution with location = 0, scale = 1
(corresponding to the standard normal distribution), and
various values of shape.
§Example
use rand_distr::{SkewNormal, Distribution};
// location 2, scale 3, shape 1
let skew_normal = SkewNormal::new(2.0, 3.0, 1.0).unwrap();
let v = skew_normal.sample(&mut rand::rng());
println!("{} is from a SN(2, 3, 1) distribution", v)§Implementation details
We are using the algorithm from A Method to Simulate the Skew Normal Distribution.
Implementations§
Source§impl<F> SkewNormal<F>
impl<F> SkewNormal<F>
Sourcepub fn new(location: F, scale: F, shape: F) -> Result<SkewNormal<F>, Error>
pub fn new(location: F, scale: F, shape: F) -> Result<SkewNormal<F>, Error>
Construct, from location, scale and shape.
Parameters:
- location (unrestricted)
- scale (must be finite and larger than zero)
- shape (must be finite)
Trait Implementations§
Source§impl<F> Clone for SkewNormal<F>
impl<F> Clone for SkewNormal<F>
Source§fn clone(&self) -> SkewNormal<F>
fn clone(&self) -> SkewNormal<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F> Debug for SkewNormal<F>
impl<F> Debug for SkewNormal<F>
Source§impl<F> Distribution<F> for SkewNormal<F>
impl<F> Distribution<F> for SkewNormal<F>
Source§impl<F> PartialEq for SkewNormal<F>
impl<F> PartialEq for SkewNormal<F>
impl<F> Copy for SkewNormal<F>
impl<F> StructuralPartialEq for SkewNormal<F>
Auto Trait Implementations§
impl<F> Freeze for SkewNormal<F>where
F: Freeze,
impl<F> RefUnwindSafe for SkewNormal<F>where
F: RefUnwindSafe,
impl<F> Send for SkewNormal<F>where
F: Send,
impl<F> Sync for SkewNormal<F>where
F: Sync,
impl<F> Unpin for SkewNormal<F>where
F: Unpin,
impl<F> UnwindSafe for SkewNormal<F>where
F: 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
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<D, T> DistributionExt<T> for Dwhere
D: Distribution<T>,
impl<D, T> DistributionExt<T> for Dwhere
D: Distribution<T>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
Source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
Source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
Source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
Source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
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>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.