Struct statrs::distribution::Beta
source · [−]pub struct Beta { /* private fields */ }
Expand description
Implementations
Constructs a new beta distribution with shapeA (α) of shape_a
and shapeB (β) of shape_b
Errors
Returns an error if shape_a
or shape_b
are NaN
.
Also returns an error if shape_a <= 0.0
or shape_b <= 0.0
Examples
use statrs::distribution::Beta;
let mut result = Beta::new(2.0, 2.0);
assert!(result.is_ok());
result = Beta::new(0.0, 0.0);
assert!(result.is_err());
Returns the shapeA (α) of the beta distribution
Examples
use statrs::distribution::Beta;
let n = Beta::new(2.0, 2.0).unwrap();
assert_eq!(n.shape_a(), 2.0);
Trait Implementations
Calculates the probability density function for the beta distribution
at x
.
Formula
let B(α, β) = Γ(α)Γ(β)/Γ(α + β)
x^(α - 1) * (1 - x)^(β - 1) / B(α, β)
where α
is shapeA, β
is shapeB, and Γ
is the gamma function
Calculates the cumulative distribution function for the beta
distribution
at x
Formula
I_x(α, β)
where α
is shapeA, β
is shapeB, and I_x
is the regularized
lower incomplete beta function
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 entropy of the beta distribution
Formula
ln(B(α, β)) - (α - 1)ψ(α) - (β - 1)ψ(β) + (α + β - 2)ψ(α + β)
where α
is shapeA, β
is shapeB and ψ
is the digamma function
Returns the skewness of the Beta distribution
Formula
2(β - α) * sqrt(α + β + 1) / ((α + β + 2) * sqrt(αβ))
where α
is shapeA and β
is shapeB
Auto Trait Implementations
impl RefUnwindSafe for Beta
impl UnwindSafe for Beta
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.