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

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);

Methods

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 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

This example is not tested
(x - min) / (max - min)

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

This example is not tested
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

This example is not tested
ln(1 / (max - min))

impl Min<f64> for Uniform[src]

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

This example is not tested
(min + max) / 2

impl Variance<f64> for Uniform[src]

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

Returns the variance for the continuous uniform distribution

Formula

This example is not tested
(max - min)^2 / 12

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

Returns the standard deviation for the continuous uniform distribution

Formula

This example is not tested
sqrt((max - min)^2 / 12)

impl Entropy<f64> for Uniform[src]

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

Returns the entropy for the continuous uniform distribution

Formula

This example is not tested
ln(max - min)

impl Skewness<f64> for Uniform[src]

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

Returns the skewness for the continuous uniform distribution

Formula

This example is not tested
0

impl Median<f64> for Uniform[src]

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

Returns the median for the continuous uniform distribution

Formula

This example is not tested
(min + max) / 2

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

This example is not tested
N/A // (max + min) / 2 for the middle element

impl Copy for Uniform[src]

impl Clone for Uniform[src]

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

Performs copy-assignment from source. Read more

impl PartialEq<Uniform> for Uniform[src]

impl Debug for Uniform[src]

impl Distribution<f64> for Uniform[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

Auto Trait Implementations

impl Send for Uniform

impl Sync for Uniform

Blanket Implementations

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

impl<T> From<T> for 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<T> Borrow<T> for T where
    T: ?Sized
[src]

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

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