pub struct Uniform { /* private fields */ }
Expand description
Uniform distribution: X ~ Uni(a, b)
Implementations§
Trait Implementations§
Source§impl Distribution for Uniform
impl Distribution for Uniform
Source§fn cf(&self, t: f64) -> Complex<f64>
fn cf(&self, t: f64) -> Complex<f64>
Characteristic function of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
let cf = dist.cf(1.0);
assert_approx_equal!(cf.re, 0.8414710, 1e-7);
assert_approx_equal!(cf.im, 0.4596977, 1e-7);
Source§fn pdf(&self, x: f64) -> f64
fn pdf(&self, x: f64) -> f64
Probability density function of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.pdf(0.5), 1.0, 1e-7);
Source§fn pmf(&self, x: f64) -> f64
fn pmf(&self, x: f64) -> f64
Probability mass function of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Discrete);
assert_approx_equal!(dist.pmf(0.5), 0.5, 1e-7);
Source§fn cdf(&self, x: f64) -> f64
fn cdf(&self, x: f64) -> f64
Cumulative distribution function of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.cdf(0.5), 0.5, 1e-7);
Source§fn inv_cdf(&self, p: f64) -> f64
fn inv_cdf(&self, p: f64) -> f64
Inverse distribution (quantile) function of the Uniform distribution. Note: Only implemented for the continuous distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.inv_cdf(0.5), 0.5, 1e-7);
Source§fn mean(&self) -> f64
fn mean(&self) -> f64
Mean of the Uniform distribution. The mean of the Uniform distribution is equal to its median.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.mean(), 0.5, 1e-7);
Source§fn median(&self) -> f64
fn median(&self) -> f64
Median of the Uniform distribution. The mean of the Uniform distribution is equal to its median.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.median(), 0.5, 1e-7);
Source§fn mode(&self) -> f64
fn mode(&self) -> f64
Mode of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.mode(), 0.5, 1e-7);
Source§fn variance(&self) -> f64
fn variance(&self) -> f64
Variance of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.variance(), 0.0833333, 1e-7);
Source§fn skewness(&self) -> f64
fn skewness(&self) -> f64
Skewness of the Uniform distribution. The skewness of the Uniform distribution is equal to 0.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_eq!(dist.skewness(), 0.0);
Source§fn kurtosis(&self) -> f64
fn kurtosis(&self) -> f64
Kurtosis of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.kurtosis(), -6.0/5.0, 1e-7);
Source§fn entropy(&self) -> f64
fn entropy(&self) -> f64
Entropy of the Uniform distribution.
§Examples
let dist = Uniform::new(0.5, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.entropy(), -0.6931472, 1e-7);
Source§fn mgf(&self, t: f64) -> f64
fn mgf(&self, t: f64) -> f64
Moment generating function of the Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
assert_approx_equal!(dist.mgf(1.0), 1.7182818, 1e-7);
Source§fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
fn sample(&self, n: usize) -> Result<Vec<f64>, RustQuantError>
Generates a random sample from a Uniform distribution.
§Examples
let dist = Uniform::new(0.0, 1.0, DistributionClass::Continuous);
let sample = dist.sample(1000).unwrap();
let mean = sample.iter().sum::<f64>() / sample.len() as f64;
assert_approx_equal!(mean, dist.mean(), 0.1);
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
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>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.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>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
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
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.