pub struct Uniform { /* private fields */ }Expand description
Continuous uniform distribution on [min, max].
§Mathematical Definition
- PDF: f(x) = 1/(max−min) for x ∈ [min, max]
- CDF: F(x) = (x−min)/(max−min)
- Mean: (min+max)/2
- Variance: (max−min)²/12
Implementations§
Source§impl Uniform
impl Uniform
Sourcepub fn new(min: f64, max: f64) -> Result<Self, DistributionError>
pub fn new(min: f64, max: f64) -> Result<Self, DistributionError>
Creates a new uniform distribution on [min, max].
§Errors
Returns Err if min >= max or either parameter is not finite.
pub fn min(&self) -> f64
pub fn max(&self) -> f64
pub fn mean(&self) -> f64
pub fn variance(&self) -> f64
Trait Implementations§
impl StructuralPartialEq for Uniform
Auto Trait Implementations§
impl Freeze for Uniform
impl RefUnwindSafe for Uniform
impl Send for Uniform
impl Sync for Uniform
impl Unpin for Uniform
impl UnsafeUnpin for Uniform
impl UnwindSafe for Uniform
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more