# [−][src]Struct statrs::distribution::Exponential

`pub struct Exponential { /* fields omitted */ }`

Implements the Exponential distribution and is a special case of the Gamma distribution (referenced here)

# Examples

```use statrs::distribution::{Exponential, Continuous};
use statrs::statistics::Mean;

let n = Exponential::new(1.0).unwrap();
assert_eq!(n.mean(), 1.0);
assert_eq!(n.pdf(1.0), 0.3678794411714423215955);```

## Methods

### `impl Exponential`[src]

#### `pub fn new(rate: f64) -> Result<Exponential>`[src]

Constructs a new exponential distribution with a rate (λ) of `rate`.

# Errors

Returns an error if rate is `NaN` or `rate <= 0.0`

# Examples

```use statrs::distribution::Exponential;

let mut result = Exponential::new(1.0);
assert!(result.is_ok());

result = Exponential::new(-1.0);
assert!(result.is_err());```

#### `pub fn rate(&self) -> f64`[src]

Returns the rate of the exponential distribution

# Examples

```use statrs::distribution::Exponential;

let n = Exponential::new(1.0).unwrap();
assert_eq!(n.rate(), 1.0);```

## Trait Implementations

### `impl Univariate<f64, f64> for Exponential`[src]

#### `fn cdf(&self, x: f64) -> f64`[src]

Calculates the cumulative distribution function for the exponential distribution at `x`

# Formula

`1 - e^(-λ * x)`

where `λ` is the rate

### `impl Continuous<f64, f64> for Exponential`[src]

#### `fn pdf(&self, x: f64) -> f64`[src]

Calculates the probability density function for the exponential distribution at `x`

# Formula

`λ * e^(-λ * x)`

where `λ` is the rate

#### `fn ln_pdf(&self, x: f64) -> f64`[src]

Calculates the log probability density function for the exponential distribution at `x`

# Formula

`ln(λ * e^(-λ * x))`

where `λ` is the rate

### `impl Min<f64> for Exponential`[src]

#### `fn min(&self) -> f64`[src]

Returns the minimum value in the domain of the exponential distribution representable by a double precision float

# Formula

`0`

### `impl Max<f64> for Exponential`[src]

#### `fn max(&self) -> f64`[src]

Returns the maximum value in the domain of the exponential distribution representable by a double precision float

# Formula

`INF`

### `impl Mean<f64> for Exponential`[src]

#### `fn mean(&self) -> f64`[src]

Returns the mean of the exponential distribution

# Formula

`1 / λ`

where `λ` is the rate

### `impl Variance<f64> for Exponential`[src]

#### `fn variance(&self) -> f64`[src]

Returns the variance of the exponential distribution

# Formula

`1 / λ^2`

where `λ` is the rate

#### `fn std_dev(&self) -> f64`[src]

Returns the standard deviation of the exponential distribution

# Formula

`sqrt(1 / λ^2)`

where `λ` is the rate

### `impl Entropy<f64> for Exponential`[src]

#### `fn entropy(&self) -> f64`[src]

Returns the entropy of the exponential distribution

# Formula

`1 - ln(λ)`

where `λ` is the rate

### `impl Skewness<f64> for Exponential`[src]

#### `fn skewness(&self) -> f64`[src]

Returns the skewness of the exponential distribution

# Formula

`2`

### `impl Median<f64> for Exponential`[src]

#### `fn median(&self) -> f64`[src]

Returns the median of the exponential distribution

# Formula

`(1 / λ) * ln2`

where `λ` is the rate

### `impl Mode<f64> for Exponential`[src]

#### `fn mode(&self) -> f64`[src]

Returns the mode of the exponential distribution

# Formula

`0`

### `impl Clone for Exponential`[src]

#### `fn clone_from(&mut self, source: &Self)`1.0.0[src]

Performs copy-assignment from `source`. Read more

### `impl Distribution<f64> for Exponential`[src]

#### `fn sample_iter<R>(&'a self, rng: &'a mut R) -> DistIter<'a, Self, R, T> where    R: Rng, `[src]

Create an iterator that generates random values of `T`, using `rng` as the source of randomness. Read more

## Blanket Implementations

### `impl<T> ToOwned for T where    T: Clone, `[src]

#### `type Owned = T`

The resulting type after obtaining ownership.

### `impl<T, U> TryFrom<U> for T where    U: Into<T>, `[src]

#### `type Error = Infallible`

The type returned in the event of a conversion error.

### `impl<T, U> TryInto<U> for T where    U: TryFrom<T>, `[src]

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

The type returned in the event of a conversion error.