Struct statrs::distribution::DiscreteUniform [−][src]
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);
Implementations
impl DiscreteUniform
[src]
pub fn new(min: i64, max: i64) -> Result<DiscreteUniform>
[src]
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 Clone for DiscreteUniform
[src]
fn clone(&self) -> DiscreteUniform
[src]
pub fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for DiscreteUniform
[src]
impl Debug for DiscreteUniform
[src]
impl Discrete<i64, f64> for DiscreteUniform
[src]
fn pmf(&self, x: i64) -> f64
[src]
Calculates the probability mass function for the discrete uniform
distribution at x
Remarks
Returns 0.0
if x
is not in [min, max]
Formula
1 / (max - min + 1)
fn ln_pmf(&self, x: i64) -> f64
[src]
impl Distribution<f64> for DiscreteUniform
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
pub fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
R: Rng,
impl Entropy<f64> for DiscreteUniform
[src]
impl Max<i64> for DiscreteUniform
[src]
fn max(&self) -> i64
[src]
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 Median<f64> for DiscreteUniform
[src]
impl Min<i64> for DiscreteUniform
[src]
fn min(&self) -> i64
[src]
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 Mode<i64> for DiscreteUniform
[src]
impl PartialEq<DiscreteUniform> for DiscreteUniform
[src]
fn eq(&self, other: &DiscreteUniform) -> bool
[src]
fn ne(&self, other: &DiscreteUniform) -> bool
[src]
impl Skewness<f64> for DiscreteUniform
[src]
impl StructuralPartialEq for DiscreteUniform
[src]
impl Univariate<i64, f64> for DiscreteUniform
[src]
fn cdf(&self, x: f64) -> f64
[src]
Calculates the cumulative distribution function for the
discrete uniform distribution at x
Formula
(floor(x) - min + 1) / (max - min + 1)
impl Variance<f64> for DiscreteUniform
[src]
Auto Trait Implementations
impl RefUnwindSafe for DiscreteUniform
impl Send for DiscreteUniform
impl Sync for DiscreteUniform
impl Unpin for DiscreteUniform
impl UnwindSafe for DiscreteUniform
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,