Struct statrs::distribution::Pareto
source · [−]pub struct Pareto { /* private fields */ }
Expand description
Implementations
Constructs a new Pareto distribution with scale scale
, and shape
shape.
Errors
Returns an error if any of scale
or shape
are NaN
.
Returns an error if scale <= 0.0
or shape <= 0.0
Examples
use statrs::distribution::Pareto;
let mut result = Pareto::new(1.0, 2.0);
assert!(result.is_ok());
result = Pareto::new(0.0, 0.0);
assert!(result.is_err());
Returns the scale of the Pareto distribution
Examples
use statrs::distribution::Pareto;
let n = Pareto::new(1.0, 2.0).unwrap();
assert_eq!(n.scale(), 1.0);
Trait Implementations
Calculates the probability density function for the Pareto distribution
at x
Formula
if x < x_m {
0
} else {
(α * x_m^α)/(x^(α + 1))
}
where x_m
is the scale and α
is the shape
Calculates the cumulative distribution function for the Pareto
distribution at x
Formula
if x < x_m {
0
} else {
1 - (x_m/x)^α
}
where x_m
is the scale and α
is the shape
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
Returns the mean of the Pareto distribution
Formula
if α <= 1 {
INF
} else {
(α * x_m)/(α - 1)
}
where x_m
is the scale and α
is the shape
Returns the variance of the Pareto distribution
Formula
if α <= 2 {
INF
} else {
(x_m/(α - 1))^2 * (α/(α - 2))
}
where x_m
is the scale and α
is the shape
Returns the entropy for the Pareto distribution
Formula
ln(α/x_m) - 1/α - 1
where x_m
is the scale and α
is the shape
Auto Trait Implementations
impl RefUnwindSafe for Pareto
impl UnwindSafe for Pareto
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.