Struct statrs::distribution::DiscreteUniform
source · [−]pub struct DiscreteUniform { /* private fields */ }
Expand description
Implements the Discrete Uniform distribution
Examples
use statrs::distribution::{DiscreteUniform, Discrete};
use statrs::statistics::Distribution;
let n = DiscreteUniform::new(0, 5).unwrap();
assert_eq!(n.mean().unwrap(), 2.5);
assert_eq!(n.pmf(3), 1.0 / 6.0);
Implementations
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
Calculates the cumulative distribution function for the
discrete uniform distribution at x
Formula
(floor(x) - min + 1) / (max - min + 1)
Due to issues with rounding and floating-point accuracy the default implementation may be ill-behaved Specialized inverse cdfs should be used whenever possible. Read more
Generate a random value of T
, using rng
as the source of randomness.
Create an iterator that generates random values of T
, using rng
as
the source of randomness. Read more
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
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
Mutably borrows from an owned value. Read more
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
Checks if self
is actually part of its subset T
(and can be converted to it).
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
The inclusion map: converts self
to the equivalent element of its superset.