Struct rv::dist::Laplace [−][src]
pub struct Laplace { /* fields omitted */ }
Laplace, or double exponential, distribution over x in (-∞, ∞).
Example
use rv::prelude::*; let laplace = Laplace::new(0.0, 1.0).expect("Invalid params"); // 100 draws from Laplace let mut rng = rand::thread_rng(); let xs: Vec<f64> = laplace.sample(100, &mut rng); assert_eq!(xs.len(), 100);
Implementations
impl Laplace
[src]
impl Laplace
[src]pub fn new(mu: f64, b: f64) -> Result<Self, LaplaceError>
[src]
Create a new Laplace distribution.
pub fn new_unchecked(mu: f64, b: f64) -> Self
[src]
Creates a new Laplace without checking whether the parameters are valid.
pub fn mu(&self) -> f64
[src]
Get the mu parameter
Examples
let laplace = Laplace::new(-1.0, 2.0).unwrap(); assert_eq!(laplace.mu(), -1.0);
pub fn set_mu(&mut self, mu: f64) -> Result<(), LaplaceError>
[src]
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());
pub fn set_mu_unchecked(&mut self, mu: f64)
[src]
Set the value of the mu parameter without input validation
pub fn b(&self) -> f64
[src]
Get the b parameter
Examples
let laplace = Laplace::new(-1.0, 2.0).unwrap(); assert_eq!(laplace.b(), 2.0);
pub fn set_b(&mut self, b: f64) -> Result<(), LaplaceError>
[src]
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());
pub fn set_b_unchecked(&mut self, b: f64)
[src]
Set the value of the b parameter without input validation
Trait Implementations
impl ContinuousDistr<f32> for Laplace
[src]
impl ContinuousDistr<f32> for Laplace
[src]impl ContinuousDistr<f64> for Laplace
[src]
impl ContinuousDistr<f64> for Laplace
[src]impl StructuralPartialEq for Laplace
[src]
impl StructuralPartialEq for Laplace
[src]Auto Trait Implementations
impl RefUnwindSafe for Laplace
impl RefUnwindSafe for Laplace
impl UnwindSafe for Laplace
impl UnwindSafe for Laplace
Blanket Implementations
impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
pub fn to_subset(&self) -> Option<SS>
pub fn is_in_subset(&self) -> bool
pub fn to_subset_unchecked(&self) -> SS
pub fn from_subset(element: &SS) -> SP
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,