pub struct Laplace { /* private fields */ }
Expand description
Implementations§
source§impl Laplace
impl Laplace
sourcepub fn new_unchecked(mu: f64, b: f64) -> Self
pub fn new_unchecked(mu: f64, b: f64) -> Self
Creates a new Laplace without checking whether the parameters are valid.
sourcepub fn mu(&self) -> f64
pub fn mu(&self) -> f64
Get the mu parameter
§Examples
let laplace = Laplace::new(-1.0, 2.0).unwrap();
assert_eq!(laplace.mu(), -1.0);
sourcepub fn set_mu(&mut self, mu: f64) -> Result<(), LaplaceError>
pub fn set_mu(&mut self, mu: f64) -> Result<(), LaplaceError>
Set the value of the mu parameter
§Example
let mut laplace = Laplace::new(-1.0, 2.0).unwrap();
assert_eq!(laplace.mu(), -1.0);
laplace.set_mu(2.3).unwrap();
assert_eq!(laplace.mu(), 2.3);
Will error for invalid values
assert!(laplace.set_mu(0.0).is_ok());
assert!(laplace.set_mu(std::f64::INFINITY).is_err());
assert!(laplace.set_mu(std::f64::NEG_INFINITY).is_err());
assert!(laplace.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 the mu parameter without input validation
sourcepub fn b(&self) -> f64
pub fn b(&self) -> f64
Get the b parameter
§Examples
let laplace = Laplace::new(-1.0, 2.0).unwrap();
assert_eq!(laplace.b(), 2.0);
sourcepub fn set_b(&mut self, b: f64) -> Result<(), LaplaceError>
pub fn set_b(&mut self, b: f64) -> Result<(), LaplaceError>
Set the value of the b parameter
§Example
let mut laplace = Laplace::new(-1.0, 2.0).unwrap();
assert_eq!(laplace.b(), 2.0);
laplace.set_b(2.3).unwrap();
assert_eq!(laplace.b(), 2.3);
Will error for invalid values
assert!(laplace.set_b(2.3).is_ok());
assert!(laplace.set_b(0.0).is_err());
assert!(laplace.set_b(std::f64::INFINITY).is_err());
assert!(laplace.set_b(std::f64::NEG_INFINITY).is_err());
assert!(laplace.set_b(std::f64::NAN).is_err());
sourcepub fn set_b_unchecked(&mut self, b: f64)
pub fn set_b_unchecked(&mut self, b: f64)
Set the value of the b parameter without input validation
Trait Implementations§
source§impl ContinuousDistr<f32> for Laplace
impl ContinuousDistr<f32> for Laplace
source§impl ContinuousDistr<f64> for Laplace
impl ContinuousDistr<f64> for Laplace
source§impl<'de> Deserialize<'de> for Laplace
impl<'de> Deserialize<'de> for Laplace
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 PartialEq for Laplace
impl PartialEq for Laplace
impl StructuralPartialEq for Laplace
Auto Trait Implementations§
impl Freeze for Laplace
impl RefUnwindSafe for Laplace
impl Send for Laplace
impl Sync for Laplace
impl Unpin for Laplace
impl UnwindSafe for Laplace
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.