Struct statrs::distribution::Uniform[][src]

pub struct Uniform { /* fields omitted */ }

Implements the Continuous Uniform distribution

Examples

use statrs::distribution::{Uniform, Continuous};
use statrs::statistics::Mean;

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

Implementations

impl Uniform[src]

pub fn new(min: f64, max: f64) -> Result<Uniform>[src]

Constructs a new uniform distribution with a min of min and a max of max

Errors

Returns an error if min or max are NaN

Examples

use statrs::distribution::Uniform;
use std::f64;

let mut result = Uniform::new(0.0, 1.0);
assert!(result.is_ok());

result = Uniform::new(f64::NAN, f64::NAN);
assert!(result.is_err());

Trait Implementations

impl Clone for Uniform[src]

impl Continuous<f64, f64> for Uniform[src]

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

Calculates the probability density function for the continuous uniform distribution at x

Remarks

Returns 0.0 if x is not in [min, max]

Formula

1 / (max - min)

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

Calculates the log probability density function for the continuous uniform distribution at x

Remarks

Returns f64::NEG_INFINITY if x is not in [min, max]

Formula

ln(1 / (max - min))

impl Copy for Uniform[src]

impl Debug for Uniform[src]

impl Distribution<f64> for Uniform[src]

impl Entropy<f64> for Uniform[src]

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

Returns the entropy for the continuous uniform distribution

Formula

ln(max - min)

impl Max<f64> for Uniform[src]

impl Mean<f64> for Uniform[src]

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

Returns the mean for the continuous uniform distribution

Formula

(min + max) / 2

impl Median<f64> for Uniform[src]

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

Returns the median for the continuous uniform distribution

Formula

(min + max) / 2

impl Min<f64> for Uniform[src]

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 PartialEq<Uniform> for Uniform[src]

impl Skewness<f64> for Uniform[src]

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

Returns the skewness for the continuous uniform distribution

Formula

0

impl StructuralPartialEq for Uniform[src]

impl Univariate<f64, f64> for Uniform[src]

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

Calculates the cumulative distribution function for the uniform distribution at x

Formula

(x - min) / (max - min)

impl Variance<f64> for Uniform[src]

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

Returns the variance for the continuous uniform distribution

Formula

(max - min)^2 / 12

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

Returns the standard deviation for the continuous uniform distribution

Formula

sqrt((max - min)^2 / 12)

Auto Trait Implementations

impl RefUnwindSafe for Uniform

impl Send for Uniform

impl Sync for Uniform

impl Unpin for Uniform

impl UnwindSafe for Uniform

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

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.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 
[src]