Skip to main content

Exponential

Struct Exponential 

Source
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: f64

Rate parameter λ > 0

Implementations§

Source§

impl Exponential

Source

pub fn new(lambda: f64) -> StatsResult<Self>

Creates an Exponential distribution with validation.

Source

pub fn fit(data: &[f64]) -> StatsResult<Self>

MLE: λ = 1 / mean(data). Data must be non-negative.

Trait Implementations§

Source§

impl Clone for Exponential

Source§

fn clone(&self) -> Exponential

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Exponential

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Distribution for Exponential

Source§

fn name(&self) -> &str

Human-readable distribution name, e.g. "Normal".
Source§

fn num_params(&self) -> usize

Number of free parameters (used when computing AIC / BIC).
Source§

fn pdf(&self, x: f64) -> StatsResult<f64>

Probability density function f(x).
Source§

fn logpdf(&self, x: f64) -> StatsResult<f64>

Natural logarithm of the PDF: ln f(x). Read more
Source§

fn cdf(&self, x: f64) -> StatsResult<f64>

Cumulative distribution function F(x) = P(X ≤ x).
Source§

fn inverse_cdf(&self, p: f64) -> StatsResult<f64>

Quantile (inverse CDF): find x such that F(x) = p.
Source§

fn mean(&self) -> f64

Mean (expected value) μ.
Source§

fn variance(&self) -> f64

Variance σ².
Source§

fn std_dev(&self) -> f64

Standard deviation σ = √(variance).
Source§

fn log_likelihood(&self, data: &[f64]) -> StatsResult<f64>

Sum of log-likelihoods: Σ ln f(xᵢ).
Source§

fn aic(&self, data: &[f64]) -> StatsResult<f64>

Akaike Information Criterion: AIC = 2k − 2·ln(L̂).
Source§

fn bic(&self, data: &[f64]) -> StatsResult<f64>

Bayesian Information Criterion: BIC = k·ln(n) − 2·ln(L̂).
Source§

impl Copy for Exponential

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.