Struct statrs::distribution::Uniform
source · [−]pub struct Uniform { /* private fields */ }
Expand description
Implements the Continuous Uniform distribution
Examples
use statrs::distribution::{Uniform, Continuous};
use statrs::statistics::Distribution;
let n = Uniform::new(0.0, 1.0).unwrap();
assert_eq!(n.mean().unwrap(), 0.5);
assert_eq!(n.pdf(0.5), 1.0);
Implementations
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
Calculates the cumulative distribution function for the uniform
distribution
at x
Formula
(x - min) / (max - min)
Due to issues with rounding and floating-point accuracy the default
implementation may be ill-behaved.
Specialized inverse cdfs should be used whenever possible.
Performs a binary search on the domain of cdf
to obtain an approximation
of F^-1(p) := inf { x | F(x) >= p }
. Needless to say, performance may
may be lacking. 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
Auto Trait Implementations
impl RefUnwindSafe for Uniform
impl UnwindSafe for Uniform
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.