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(f64::INFINITY).is_err());
assert!(laplace.set_mu(f64::NEG_INFINITY).is_err());
assert!(laplace.set_mu(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(f64::INFINITY).is_err());
assert!(laplace.set_b(f64::NEG_INFINITY).is_err());
assert!(laplace.set_b(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 HasDensity<f32> for Laplace
impl HasDensity<f32> for Laplace
source§impl HasDensity<f64> for Laplace
impl HasDensity<f64> for Laplace
source§impl Parameterized for Laplace
impl Parameterized for Laplace
type Parameters = LaplaceParameters
fn emit_params(&self) -> Self::Parameters
fn from_params(params: Self::Parameters) -> Self
source§impl PartialEq for Laplace
impl PartialEq for Laplace
source§impl Sampleable<f32> for Laplace
impl Sampleable<f32> for Laplace
source§impl Sampleable<f64> for Laplace
impl Sampleable<f64> 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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
Converts
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<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.