pub struct Pareto { /* private fields */ }
Expand description
Pareto distribution Pareto(x_m, α) over x in (x_m, ∞).
NOTE: The Pareto distribution is parameterized in terms of shape, α, and scale, x_m.
α x_m^α
f(x|α, x_m) = ---------
x^(α + 1)
Implementations§
source§impl Pareto
impl Pareto
sourcepub fn new(shape: f64, scale: f64) -> Result<Self, ParetoError>
pub fn new(shape: f64, scale: f64) -> Result<Self, ParetoError>
Create a new Pareto
distribution with shape (α) and scale (x_m).
sourcepub fn new_unchecked(shape: f64, scale: f64) -> Self
pub fn new_unchecked(shape: f64, scale: f64) -> Self
Creates a new Pareto without checking whether the parameters are valid.
sourcepub fn shape(&self) -> f64
pub fn shape(&self) -> f64
Get shape parameter
§Example
let pareto = Pareto::new(1.0, 2.0).unwrap();
assert_eq!(pareto.shape(), 1.0);
sourcepub fn set_shape(&mut self, shape: f64) -> Result<(), ParetoError>
pub fn set_shape(&mut self, shape: f64) -> Result<(), ParetoError>
Set the shape parameter
§Example
use rv::dist::Pareto;
let mut pareto = Pareto::new(2.0, 1.0).unwrap();
assert_eq!(pareto.shape(), 2.0);
pareto.set_shape(1.1).unwrap();
assert_eq!(pareto.shape(), 1.1);
Will error for invalid values
assert!(pareto.set_shape(1.1).is_ok());
assert!(pareto.set_shape(0.0).is_err());
assert!(pareto.set_shape(-1.0).is_err());
assert!(pareto.set_shape(f64::INFINITY).is_err());
assert!(pareto.set_shape(f64::NEG_INFINITY).is_err());
assert!(pareto.set_shape(f64::NAN).is_err());
sourcepub fn set_shape_unchecked(&mut self, shape: f64)
pub fn set_shape_unchecked(&mut self, shape: f64)
Set the shape parameter without input validation
sourcepub fn scale(&self) -> f64
pub fn scale(&self) -> f64
Get scale parameter
§Example
let pareto = Pareto::new(1.0, 2.0).unwrap();
assert_eq!(pareto.scale(), 2.0);
sourcepub fn set_scale(&mut self, scale: f64) -> Result<(), ParetoError>
pub fn set_scale(&mut self, scale: f64) -> Result<(), ParetoError>
Set the scale parameter
§Example
use rv::dist::Pareto;
let mut pareto = Pareto::new(2.0, 1.0).unwrap();
assert_eq!(pareto.scale(), 1.0);
pareto.set_scale(1.1).unwrap();
assert_eq!(pareto.scale(), 1.1);
Will error for invalid values
assert!(pareto.set_scale(1.1).is_ok());
assert!(pareto.set_scale(0.0).is_err());
assert!(pareto.set_scale(-1.0).is_err());
assert!(pareto.set_scale(f64::INFINITY).is_err());
assert!(pareto.set_scale(f64::NEG_INFINITY).is_err());
assert!(pareto.set_scale(f64::NAN).is_err());
sourcepub fn set_scale_unchecked(&mut self, scale: f64)
pub fn set_scale_unchecked(&mut self, scale: f64)
Set the scale parameter without input validation
Trait Implementations§
source§impl ContinuousDistr<f32> for Pareto
impl ContinuousDistr<f32> for Pareto
source§impl ContinuousDistr<f64> for Pareto
impl ContinuousDistr<f64> for Pareto
source§impl<'de> Deserialize<'de> for Pareto
impl<'de> Deserialize<'de> for Pareto
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 HasDensity<f32> for Pareto
impl HasDensity<f32> for Pareto
source§impl HasDensity<f64> for Pareto
impl HasDensity<f64> for Pareto
source§impl Parameterized for Pareto
impl Parameterized for Pareto
type Parameters = ParetoParameters
fn emit_params(&self) -> Self::Parameters
fn from_params(params: Self::Parameters) -> Self
source§impl PartialEq for Pareto
impl PartialEq for Pareto
source§impl Sampleable<f32> for Pareto
impl Sampleable<f32> for Pareto
source§impl Sampleable<f64> for Pareto
impl Sampleable<f64> for Pareto
impl StructuralPartialEq for Pareto
Auto Trait Implementations§
impl Freeze for Pareto
impl RefUnwindSafe for Pareto
impl Send for Pareto
impl Sync for Pareto
impl Unpin for Pareto
impl UnwindSafe for Pareto
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<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)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>
Converts
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>
Converts
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<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.