Struct statrs::distribution::DiscreteUniform
[−]
[src]
pub struct DiscreteUniform { /* fields omitted */ }
Implements the Discrete Uniform distribution
Examples
use statrs::distribution::{DiscreteUniform, Discrete}; use statrs::statistics::Mean; let n = DiscreteUniform::new(0, 5).unwrap(); assert_eq!(n.mean(), 2.5); assert_eq!(n.pmf(3), 1.0 / 6.0);
Methods
impl DiscreteUniform
[src]
fn new(min: i64, max: i64) -> Result<DiscreteUniform>
Constructs a new discrete uniform distribution with a minimum value
of min
and a maximum value of max
.
Errors
Returns an error if max < min
Examples
use statrs::distribution::DiscreteUniform; let mut result = DiscreteUniform::new(0, 5); assert!(result.is_ok()); result = DiscreteUniform::new(5, 0); assert!(result.is_err());
Trait Implementations
impl Debug for DiscreteUniform
[src]
impl Copy for DiscreteUniform
[src]
impl Clone for DiscreteUniform
[src]
fn clone(&self) -> DiscreteUniform
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 DiscreteUniform
[src]
fn eq(&self, __arg_0: &DiscreteUniform) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &DiscreteUniform) -> bool
This method tests for !=
.
impl Sample<f64> for DiscreteUniform
[src]
fn sample<R: Rng>(&mut self, r: &mut R) -> f64
Generate a random sample from a discrete uniform
distribution using r
as the source of randomness.
Refer here for implementation details
impl IndependentSample<f64> for DiscreteUniform
[src]
fn ind_sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random independent sample from a discrete uniform
distribution using r
as the source of randomness.
Refer here for implementation details
impl Distribution<f64> for DiscreteUniform
[src]
fn sample<R: Rng>(&self, r: &mut R) -> f64
Generate a random sample from the discrete uniform distribution
using r
as the source of randomness in the range [min, max]
Examples
use rand::StdRng; use statrs::distribution::{DiscreteUniform, Distribution}; let mut r = rand::StdRng::new().unwrap(); let n = DiscreteUniform::new(0, 5).unwrap(); print!("{}", n.sample::<StdRng>(&mut r));
impl Univariate<i64, f64> for DiscreteUniform
[src]
impl Min<i64> for DiscreteUniform
[src]
fn min(&self) -> i64
Returns the minimum value in the domain of the discrete uniform distribution
Remarks
This is the same value as the minimum passed into the constructor
impl Max<i64> for DiscreteUniform
[src]
fn max(&self) -> i64
Returns the maximum value in the domain of the discrete uniform distribution
Remarks
This is the same value as the maximum passed into the constructor
impl Mean<f64> for DiscreteUniform
[src]
impl Variance<f64> for DiscreteUniform
[src]
fn variance(&self) -> f64
fn std_dev(&self) -> f64
Returns the standard deviation of the discrete uniform distribution
Formula
sqrt(((max - min + 1)^2 - 1) / 12)