pub struct Uniform { /* private fields */ }
Expand description
Continuous uniform distribution, U(a, b) on the interval x in [a, b]
§Example
The Uniform CDF is a line
use rv::prelude::*;
let u = Uniform::new(2.0, 4.0).unwrap();
// A line representing the CDF
let y = |x: f64| { 0.5 * x - 1.0 };
assert!((u.cdf(&3.0_f64) - y(3.0)).abs() < 1E-12);
assert!((u.cdf(&3.2_f64) - y(3.2)).abs() < 1E-12);
Implementations§
source§impl Uniform
impl Uniform
sourcepub fn new(a: f64, b: f64) -> Result<Self, UniformError>
pub fn new(a: f64, b: f64) -> Result<Self, UniformError>
Create a new uniform distribution on [a, b]
sourcepub fn new_unchecked(a: f64, b: f64) -> Self
pub fn new_unchecked(a: f64, b: f64) -> Self
Creates a new Uniform without checking whether the parameters are valid.
sourcepub fn set_a_unchecked(&mut self, a: f64)
pub fn set_a_unchecked(&mut self, a: f64)
Set the value of a without checking if a is valid
sourcepub fn set_b_unchecked(&mut self, b: f64)
pub fn set_b_unchecked(&mut self, b: f64)
Set the value of b without checking if b is valid
Trait Implementations§
source§impl ContinuousDistr<f32> for Uniform
impl ContinuousDistr<f32> for Uniform
source§impl ContinuousDistr<f64> for Uniform
impl ContinuousDistr<f64> for Uniform
source§impl<'de> Deserialize<'de> for Uniform
impl<'de> Deserialize<'de> for Uniform
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl InverseCdf<f32> for Uniform
impl InverseCdf<f32> for Uniform
source§impl InverseCdf<f64> for Uniform
impl InverseCdf<f64> for Uniform
source§impl PartialEq for Uniform
impl PartialEq for Uniform
source§impl Rv<f32> for Uniform
impl Rv<f32> for Uniform
source§impl Rv<f64> for Uniform
impl Rv<f64> 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 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
source§impl<Fx> Rv<Datum> for Fxwhere
Fx: RvDatum,
impl<Fx> Rv<Datum> for Fxwhere
Fx: RvDatum,
source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.