pub struct LogNormal { /* private fields */ }
Expand description
LogNormal Distribution If x ~ Normal(μ, σ), then e^x ~ LogNormal(μ, σ).
Implementations§
source§impl LogNormal
impl LogNormal
sourcepub fn new(mu: f64, sigma: f64) -> Result<Self, LogNormalError>
pub fn new(mu: f64, sigma: f64) -> Result<Self, LogNormalError>
Create a new LogNormal distribution
§Arguments
- mu: log scale mean
- sigma: log scale standard deviation
sourcepub fn new_unchecked(mu: f64, sigma: f64) -> Self
pub fn new_unchecked(mu: f64, sigma: f64) -> Self
Creates a new LogNormal without checking whether the parameters are valid.
sourcepub fn standard() -> Self
pub fn standard() -> Self
LogNorma(0, 1)
§Example
let lognormal = LogNormal::standard();
assert_eq!(lognormal, LogNormal::new(0.0, 1.0).unwrap());
sourcepub fn mu(&self) -> f64
pub fn mu(&self) -> f64
Get the mu parameter
§Example
let lognormal = LogNormal::new(-1.0, 2.0).unwrap();
assert_eq!(lognormal.mu(), -1.0);
sourcepub fn set_mu(&mut self, mu: f64) -> Result<(), LogNormalError>
pub fn set_mu(&mut self, mu: f64) -> Result<(), LogNormalError>
Set the value of mu
§Example
let mut lognormal = LogNormal::new(2.0, 1.5).unwrap();
assert_eq!(lognormal.mu(), 2.0);
lognormal.set_mu(1.3).unwrap();
assert_eq!(lognormal.mu(), 1.3);
Will error for invalid values
assert!(lognormal.set_mu(1.3).is_ok());
assert!(lognormal.set_mu(std::f64::NEG_INFINITY).is_err());
assert!(lognormal.set_mu(std::f64::INFINITY).is_err());
assert!(lognormal.set_mu(std::f64::NAN).is_err());
sourcepub fn set_mu_unchecked(&mut self, mu: f64)
pub fn set_mu_unchecked(&mut self, mu: f64)
Set the value of mu without input validation
sourcepub fn sigma(&self) -> f64
pub fn sigma(&self) -> f64
Get the sigma parameter
§Example
let lognormal = LogNormal::new(-1.0, 2.0).unwrap();
assert_eq!(lognormal.sigma(), 2.0);
sourcepub fn set_sigma(&mut self, sigma: f64) -> Result<(), LogNormalError>
pub fn set_sigma(&mut self, sigma: f64) -> Result<(), LogNormalError>
Set the value of sigma
§Example
let mut lognormal = LogNormal::standard();
assert_eq!(lognormal.sigma(), 1.0);
lognormal.set_sigma(2.3).unwrap();
assert_eq!(lognormal.sigma(), 2.3);
Will error for invalid values
assert!(lognormal.set_sigma(2.3).is_ok());
assert!(lognormal.set_sigma(0.0).is_err());
assert!(lognormal.set_sigma(-1.0).is_err());
assert!(lognormal.set_sigma(std::f64::INFINITY).is_err());
assert!(lognormal.set_sigma(std::f64::NEG_INFINITY).is_err());
assert!(lognormal.set_sigma(std::f64::NAN).is_err());
sourcepub fn set_sigma_unchecked(&mut self, sigma: f64)
pub fn set_sigma_unchecked(&mut self, sigma: f64)
Set the value of sigma
Trait Implementations§
source§impl ContinuousDistr<f32> for LogNormal
impl ContinuousDistr<f32> for LogNormal
source§impl ContinuousDistr<f64> for LogNormal
impl ContinuousDistr<f64> for LogNormal
source§impl<'de> Deserialize<'de> for LogNormal
impl<'de> Deserialize<'de> for LogNormal
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 InverseCdf<f32> for LogNormal
impl InverseCdf<f32> for LogNormal
source§impl InverseCdf<f64> for LogNormal
impl InverseCdf<f64> for LogNormal
source§impl PartialEq for LogNormal
impl PartialEq for LogNormal
source§impl Rv<f32> for LogNormal
impl Rv<f32> for LogNormal
source§impl Rv<f64> for LogNormal
impl Rv<f64> for LogNormal
impl StructuralPartialEq for LogNormal
Auto Trait Implementations§
impl Freeze for LogNormal
impl RefUnwindSafe for LogNormal
impl Send for LogNormal
impl Sync for LogNormal
impl Unpin for LogNormal
impl UnwindSafe for LogNormal
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<Fx> Rv<Datum> for Fxwhere
Fx: RvDatum,
impl<Fx> Rv<Datum> for Fxwhere
Fx: RvDatum,
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.