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);
Methods
impl Uniform
[src]
fn new(min: f64, max: f64) -> Result<Uniform>
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 Debug for Uniform
[src]
impl Copy for Uniform
[src]
impl Clone for Uniform
[src]
fn clone(&self) -> Uniform
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for Uniform
[src]
fn eq(&self, __arg_0: &Uniform) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Uniform) -> bool
This method tests for !=
.
impl Sample<f64> for Uniform
[src]
fn sample<R: Rng>(&mut self, r: &mut R) -> f64
Generate a random sample from a continuous uniform
distribution using r
as the source of randomness.
Refer here for implementation details
impl IndependentSample<f64> for Uniform
[src]
fn ind_sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random independent sample from a continuous uniform
distribution using r
as the source of randomness.
Refer here for implementation details
impl Distribution<f64> for Uniform
[src]
fn sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random sample from the continuous uniform distribution
using r
as the source of randomness in the range [min, max]
Examples
use rand::StdRng; use statrs::distribution::{Uniform, Distribution}; let mut r = rand::StdRng::new().unwrap(); let n = Uniform::new(0.0, 5.0).unwrap(); print!("{}", n.sample::<StdRng>(&mut r));
impl Univariate<f64, f64> for Uniform
[src]
impl Min<f64> for Uniform
[src]
fn min(&self) -> f64
Returns the minimum value in the domain of a given distribution representable by a double-precision float. May panic depending on the implementor. Read more
impl Max<f64> for Uniform
[src]
fn max(&self) -> f64
Returns the maximum value in the domain of a given distribution representable by a double-precision float. May panic depending on the implementor. Read more
impl Mean<f64> for Uniform
[src]
impl Variance<f64> for Uniform
[src]
fn variance(&self) -> f64
fn std_dev(&self) -> f64
Returns the standard deviation for the continuous uniform distribution
Formula
sqrt((max - min)^2 / 12)