[−][src]Struct statrs::distribution::Uniform
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
(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
1 / (max - min)
fn ln_pdf(&self, x: f64) -> f64
[src]
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
(min + max) / 2
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)
impl Entropy<f64> for Uniform
[src]
fn entropy(&self) -> f64
[src]
Returns the entropy for the continuous uniform distribution
Formula
ln(max - min)
impl Skewness<f64> for Uniform
[src]
impl Median<f64> for Uniform
[src]
fn median(&self) -> f64
[src]
Returns the median for the continuous uniform distribution
Formula
(min + max) / 2
impl Mode<f64> for Uniform
[src]
impl Copy for Uniform
[src]
impl Clone for Uniform
[src]
fn clone(&self) -> 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]
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,