Struct rv::dist::Exponential
source · pub struct Exponential { /* private fields */ }
Expand description
Exponential distribution, Exp(λ) over x in [0, ∞).
§Examples
Compute 50% confidence interval
use rv::prelude::*;
let expon = Exponential::new(1.5).unwrap();
let interval: (f64, f64) = expon.interval(0.5); // (0.19, 0.92)
Implementations§
source§impl Exponential
impl Exponential
sourcepub fn new(rate: f64) -> Result<Self, ExponentialError>
pub fn new(rate: f64) -> Result<Self, ExponentialError>
sourcepub fn new_unchecked(rate: f64) -> Self
pub fn new_unchecked(rate: f64) -> Self
Creates a new Exponential without checking whether the parameter is valid.
sourcepub fn rate(&self) -> f64
pub fn rate(&self) -> f64
Get the rate parameter
§Example
let expon = Exponential::new(1.3).unwrap();
assert_eq!(expon.rate(), 1.3);
sourcepub fn set_rate(&mut self, rate: f64) -> Result<(), ExponentialError>
pub fn set_rate(&mut self, rate: f64) -> Result<(), ExponentialError>
Set the rate parameter
§Example
let mut expon = Exponential::new(1.3).unwrap();
assert_eq!(expon.rate(), 1.3);
expon.set_rate(2.1).unwrap();
assert_eq!(expon.rate(), 2.1);
Will error for invalid values
assert!(expon.set_rate(2.1).is_ok());
assert!(expon.set_rate(0.1).is_ok());
assert!(expon.set_rate(0.0).is_err());
assert!(expon.set_rate(-1.0).is_err());
assert!(expon.set_rate(f64::INFINITY).is_err());
assert!(expon.set_rate(f64::NEG_INFINITY).is_err());
assert!(expon.set_rate(f64::NAN).is_err());
sourcepub fn set_rate_unchecked(&mut self, rate: f64)
pub fn set_rate_unchecked(&mut self, rate: f64)
Set the rate parameter without input validation
Trait Implementations§
source§impl Cdf<f32> for Exponential
impl Cdf<f32> for Exponential
source§impl Cdf<f64> for Exponential
impl Cdf<f64> for Exponential
source§impl Clone for Exponential
impl Clone for Exponential
source§fn clone(&self) -> Exponential
fn clone(&self) -> Exponential
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl ContinuousDistr<f32> for Exponential
impl ContinuousDistr<f32> for Exponential
source§impl ContinuousDistr<f64> for Exponential
impl ContinuousDistr<f64> for Exponential
source§impl Debug for Exponential
impl Debug for Exponential
source§impl Default for Exponential
impl Default for Exponential
source§impl<'de> Deserialize<'de> for Exponential
impl<'de> Deserialize<'de> for Exponential
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 Display for Exponential
impl Display for Exponential
source§impl From<&Exponential> for String
impl From<&Exponential> for String
source§fn from(expon: &Exponential) -> String
fn from(expon: &Exponential) -> String
Converts to this type from the input type.
source§impl HasDensity<f32> for Exponential
impl HasDensity<f32> for Exponential
source§impl HasDensity<f64> for Exponential
impl HasDensity<f64> for Exponential
source§impl InverseCdf<f32> for Exponential
impl InverseCdf<f32> for Exponential
source§impl InverseCdf<f64> for Exponential
impl InverseCdf<f64> for Exponential
source§impl KlDivergence for Exponential
impl KlDivergence for Exponential
source§impl Mean<f32> for Exponential
impl Mean<f32> for Exponential
source§impl Mean<f64> for Exponential
impl Mean<f64> for Exponential
source§impl Median<f32> for Exponential
impl Median<f32> for Exponential
source§impl Median<f64> for Exponential
impl Median<f64> for Exponential
source§impl Mode<f32> for Exponential
impl Mode<f32> for Exponential
source§impl Mode<f64> for Exponential
impl Mode<f64> for Exponential
source§impl Parameterized for Exponential
impl Parameterized for Exponential
type Parameters = f64
fn emit_params(&self) -> Self::Parameters
fn from_params(rate: Self::Parameters) -> Self
source§impl PartialEq for Exponential
impl PartialEq for Exponential
source§fn eq(&self, other: &Exponential) -> bool
fn eq(&self, other: &Exponential) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Sampleable<f32> for Exponential
impl Sampleable<f32> for Exponential
source§impl Sampleable<f64> for Exponential
impl Sampleable<f64> for Exponential
source§impl Serialize for Exponential
impl Serialize for Exponential
source§impl Support<f32> for Exponential
impl Support<f32> for Exponential
source§impl Support<f64> for Exponential
impl Support<f64> for Exponential
source§impl Variance<f32> for Exponential
impl Variance<f32> for Exponential
source§impl Variance<f64> for Exponential
impl Variance<f64> for Exponential
impl StructuralPartialEq for Exponential
Auto Trait Implementations§
impl Freeze for Exponential
impl RefUnwindSafe for Exponential
impl Send for Exponential
impl Sync for Exponential
impl Unpin for Exponential
impl UnwindSafe for Exponential
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.