Struct statrs::distribution::Beta [−][src]
Implements the Beta distribution
Examples
use statrs::distribution::{Beta, Continuous}; use statrs::statistics::Mean; use statrs::prec; let n = Beta::new(2.0, 2.0).unwrap(); assert_eq!(n.mean(), 0.5); assert!(prec::almost_eq(n.pdf(0.5), 1.5, 1e-14));
Implementations
impl Beta
[src]
pub fn new(shape_a: f64, shape_b: f64) -> Result<Beta>
[src]
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());
pub fn shape_a(&self) -> f64
[src]
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);
pub fn shape_b(&self) -> f64
[src]
Returns the shapeB (β) of the beta distributionβ
Examples
use statrs::distribution::Beta; let n = Beta::new(2.0, 2.0).unwrap(); assert_eq!(n.shape_b(), 2.0);
Trait Implementations
impl CheckedMode<f64> for Beta
[src]
fn checked_mode(&self) -> Result<f64>
[src]
impl Clone for Beta
[src]
impl Continuous<f64, f64> for Beta
[src]
fn pdf(&self, x: f64) -> f64
[src]
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
fn ln_pdf(&self, x: f64) -> f64
[src]
Calculates the log probability density function for the beta
distribution at x
.
Formula
let B(α, β) = Γ(α)Γ(β)/Γ(α + β) ln(x^(α - 1) * (1 - x)^(β - 1) / B(α, β))
where α
is shapeA, β
is shapeB, and Γ
is the gamma function
impl Copy for Beta
[src]
impl Debug for Beta
[src]
impl Distribution<f64> for Beta
[src]
fn sample<R: Rng + ?Sized>(&self, r: &mut R) -> f64
[src]
pub fn sample_iter<R>(self, rng: R) -> DistIter<Self, R, T> where
R: Rng,
[src]
R: Rng,
impl Entropy<f64> for Beta
[src]
fn entropy(&self) -> f64
[src]
Returns the entropy of the beta distribution
Formula
ln(B(α, β)) - (α - 1)ψ(α) - (β - 1)ψ(β) + (α + β - 2)ψ(α + β)
where α
is shapeA, β
is shapeB and ψ
is the digamma function
impl Max<f64> for Beta
[src]
fn max(&self) -> f64
[src]
Returns the maximum value in the domain of the beta distribution representable by a double precision float
Formula
1
impl Mean<f64> for Beta
[src]
impl Min<f64> for Beta
[src]
fn min(&self) -> f64
[src]
Returns the minimum value in the domain of the beta distribution representable by a double precision float
Formula
0
impl Mode<f64> for Beta
[src]
impl PartialEq<Beta> for Beta
[src]
impl Skewness<f64> for Beta
[src]
fn skewness(&self) -> f64
[src]
Returns the skewness of the Beta distribution
Formula
2(β - α) * sqrt(α + β + 1) / ((α + β + 2) * sqrt(αβ))
where α
is shapeA and β
is shapeB
impl StructuralPartialEq for Beta
[src]
impl Univariate<f64, f64> for Beta
[src]
fn cdf(&self, x: f64) -> f64
[src]
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
impl Variance<f64> for Beta
[src]
Auto Trait Implementations
impl RefUnwindSafe for Beta
impl Send for Beta
impl Sync for Beta
impl Unpin for Beta
impl UnwindSafe for Beta
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
[src]
V: MultiLane<T>,