Struct ExponentialDistribution

Source
pub struct ExponentialDistribution { /* private fields */ }
Expand description

§Description

Methods and properties of exponential distribution.

§Examples

use ndarray::{Array1, arr1};
use digifi::utilities::TEST_ACCURACY;
use digifi::statistics::{ProbabilityDistribution, ExponentialDistribution};

let dist: ExponentialDistribution = ExponentialDistribution::new(0.5).unwrap();
let x: Array1<f64> = arr1(&[0.6]);

// PDF test
let pdf_v: f64 = dist.pdf(&x).unwrap()[0];
assert!((pdf_v - 0.37040911034085894).abs() < TEST_ACCURACY);

// CDF test
let cdf_v: f64 = dist.cdf(&x).unwrap()[0];
assert!((cdf_v - 0.2591817793182821).abs() < TEST_ACCURACY);

// Inverse CDF test
let icdf_v: f64 = dist.inverse_cdf(&arr1(&[0.2591817793182821])).unwrap()[0];
assert!((icdf_v - x[0]).abs() < TEST_ACCURACY);

Implementations§

Source§

impl ExponentialDistribution

Source

pub fn new(lambda: f64) -> Result<Self, DigiFiError>

§Description

Creates a new ExponentialDistribution instance.

§Input
  • lambda: Rate parameter
§Errors
  • Returns an error if lambda is not positive.

Trait Implementations§

Source§

impl Debug for ExponentialDistribution

Source§

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

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

impl ProbabilityDistribution for ExponentialDistribution

Source§

fn pdf(&self, x: &Array1<f64>) -> Result<Array1<f64>, DigiFiError>

§Description

Calculates the Probability Density Function (PDF) for an exponential distribution.

§Input
  • x: Values at which to calculate the PDF
§Output
  • PDF values at the given x
Source§

fn cdf(&self, x: &Array1<f64>) -> Result<Array1<f64>, DigiFiError>

§Description

Computes the Cumulative Distribution Function (CDF) for an exponential distribution.

§Input
  • x: Values at which to calculate the CDF
§Output
  • CDF values at the given x
Source§

fn inverse_cdf(&self, p: &Array1<f64>) -> Result<Array1<f64>, DigiFiError>

§Description

Calculates the Inverse Cumulative Distribution Function (Inverse CDF) for an exponential distribution.

§Input
  • p: Probability values for which to calculate the inverse CDF
§Output
  • Inverse CDF values for the given probabilities
Source§

fn mgf(&self, t: &Array1<usize>) -> Array1<f64>

§Description

Computes the Moment Generating Function (MGF) for an exponential distribution.

§Input
  • t: Input values for the MGF
§Output
  • MGF values at the given t
Source§

fn mean(&self) -> f64

Description Read more
Source§

fn median(&self) -> Vec<f64>

Description Read more
Source§

fn mode(&self) -> Vec<f64>

Description Read more
Source§

fn variance(&self) -> f64

Description Read more
Source§

fn skewness(&self) -> f64

Description Read more
Source§

fn excess_kurtosis(&self) -> f64

Description Read more
Source§

fn entropy(&self) -> Result<f64, DigiFiError>

Description Read more

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

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

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.