pub struct Exponential {
pub lambda: f64,
}Expand description
Exponential distribution Exp(λ) as a typed struct.
§Examples
use rs_stats::distributions::exponential_distribution::Exponential;
use rs_stats::distributions::traits::Distribution;
let e = Exponential::new(2.0).unwrap();
assert!((e.mean() - 0.5).abs() < 1e-10);Fields§
§lambda: f64Rate parameter λ > 0
Implementations§
Source§impl Exponential
impl Exponential
Sourcepub fn new(lambda: f64) -> StatsResult<Self>
pub fn new(lambda: f64) -> StatsResult<Self>
Creates an Exponential distribution with validation.
Sourcepub fn fit(data: &[f64]) -> StatsResult<Self>
pub fn fit(data: &[f64]) -> StatsResult<Self>
MLE: λ = 1 / mean(data). Data must be non-negative.
Trait Implementations§
Source§impl Clone for Exponential
impl Clone for Exponential
Source§fn clone(&self) -> Exponential
fn clone(&self) -> Exponential
Returns a duplicate 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 Debug for Exponential
impl Debug for Exponential
Source§impl Distribution for Exponential
impl Distribution for Exponential
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Number of free parameters (used when computing AIC / BIC).
Source§fn inverse_cdf(&self, p: f64) -> StatsResult<f64>
fn inverse_cdf(&self, p: f64) -> StatsResult<f64>
Quantile (inverse CDF): find x such that F(x) = p.
Source§fn log_likelihood(&self, data: &[f64]) -> StatsResult<f64>
fn log_likelihood(&self, data: &[f64]) -> StatsResult<f64>
Sum of log-likelihoods: Σ ln f(xᵢ).
impl Copy 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 UnsafeUnpin 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