# [−][src]Trait statrs::statistics::Mode

```pub trait Mode<T> {
fn mode(&self) -> T;
}```

The `Mode` trait specififies that an object has a closed form solution for its mode(s)

## Required methods

### `fn mode(&self) -> T`

Returns the mode. May panic depending on the implementor.

# Examples

```use statrs::statistics::Mode;
use statrs::distribution::Uniform;

let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!(0.5, n.mode());```

## Implementors

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

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

Returns the mode of the Beta distribution.

# Remarks

Since the mode is technically only calculate for `α > 1, β > 1`, those are the only values we allow. We may consider relaxing this constraint in the future.

# Panics

If `α <= 1` or `β <= 1`

# Formula

`(α - 1) / (α + β - 2)`

where `α` is shapeA and `β` is shapeB

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

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

Returns the mode of the cauchy distribution

# Formula

`x_0`

where `x_0` is the location

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

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

Returns the mode for the chi distribution

# Panics

If `freedom < 1.0`

# Formula

`sqrt(k - 1)`

where `k` is the degrees of freedom

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

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

Returns the mode of the chi-squared distribution

# Formula

`k - 2`

where `k` is the degrees of freedom

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

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

Returns the mode for the erlang distribution

# Remarks

Returns `shape` if `rate ==f64::INFINITY`. This behavior is borrowed from the Math.NET implementation

# Formula

`(k - 1) / λ`

where `k` is the shape and `λ` is the rate

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

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

Returns the mode of the exponential distribution

# Formula

`0`

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

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

Returns the mode for the fisher-snedecor distribution

# Panics

If `freedom_1 <= 2.0`

# Remarks

Returns `NaN` if `freedom_1` or `freedom_2` is `INF`

# Formula

`((d1 - 2) / d1) * (d2 / (d2 + 2))`

where `d1` is the first degree of freedom and `d2` is the second degree of freedom

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

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

Returns the mode for the gamma distribution

# Remarks

Returns `shape` if `rate ==f64::INFINITY`. This behavior is borrowed from the Math.NET implementation

# Formula

`(α - 1) / β`

where `α` is the shape and `β` is the rate

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

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

Returns the mode of the inverse gamma distribution

# Formula

`β / (α + 1)`

/// where `α` is the shape and `β` is the rate

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

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

Returns the mode of the log-normal distribution

# Formula

`e^(μ - σ^2)`

where `μ` is the location and `σ` is the scale

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

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

Returns the mode of the normal distribution

# Formula

`μ`

where `μ` is the mean

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

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

Returns the mode of the Pareto distribution

# Formula

`x_m`

where `x_m` is the scale

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

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

Returns the mode of the student's t-distribution

# Formula

`μ`

where `μ` is the location

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

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

Returns the mode of the triangular distribution

# Formula

`mode`

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

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

Returns the mode for the continuous uniform distribution

# Remarks

Since every element has an equal probability, mode simply returns the middle element

# Formula

`N/A // (max + min) / 2 for the middle element`

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

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

Returns the median of the weibull distribution

# Formula

```if k == 1 {
0
} else {
λ((k - 1) / k)^(1 / k)
}```

where `k` is the shape and `λ` is the scale

### `impl Mode<i64> for DiscreteUniform`[src]

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

Returns the mode for the discrete uniform distribution

# Remarks

Since every element has an equal probability, mode simply returns the middle element

# Formula

`N/A // (max + min) / 2 for the middle element`

### `impl Mode<u64> for Bernoulli`[src]

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

Returns the mode of the bernoulli distribution

# Formula

```if p < 0.5 { 0 }
else { 1 }```

### `impl Mode<u64> for Binomial`[src]

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

Returns the mode for the binomial distribution

# Formula

`floor((n + 1) * p)`

### `impl Mode<u64> for Geometric`[src]

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

Returns the mode of the geometric distribution

# Formula

`1`

### `impl Mode<u64> for Hypergeometric`[src]

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

Returns the mode of the hypergeometric distribution

# Formula

`floor((n + 1) * (k + 1) / (N + 2))`

where `N` is population, `K` is successes, and `n` is draws

### `impl Mode<u64> for Poisson`[src]

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

Returns the mode of the poisson distribution

# Formula

`floor(λ)`

where `λ` is the rate