pub struct Gamma { /* private fields */ }
Expand description
Implementations§
Source§impl Gamma
impl Gamma
Sourcepub fn new(shape: f64, rate: f64) -> Result<Gamma, GammaError>
pub fn new(shape: f64, rate: f64) -> Result<Gamma, GammaError>
Constructs a new gamma distribution with a shape (α)
of shape
and a rate (β) of rate
§Errors
Returns an error if shape
is ‘NaN’ or inf or rate
is NaN
or inf.
Also returns an error if shape <= 0.0
or rate <= 0.0
§Examples
use statrs::distribution::Gamma;
let mut result = Gamma::new(3.0, 1.0);
assert!(result.is_ok());
result = Gamma::new(0.0, 0.0);
assert!(result.is_err());
Trait Implementations§
Source§impl Continuous<f64, f64> for Gamma
impl Continuous<f64, f64> for Gamma
Source§impl ContinuousCDF<f64, f64> for Gamma
impl ContinuousCDF<f64, f64> for Gamma
Source§fn cdf(&self, x: f64) -> f64
fn cdf(&self, x: f64) -> f64
Calculates the cumulative distribution function for the gamma
distribution
at x
§Formula
(1 / Γ(α)) * γ(α, β * x)
where α
is the shape, β
is the rate, Γ
is the gamma function,
and γ
is the lower incomplete gamma function
Source§fn sf(&self, x: f64) -> f64
fn sf(&self, x: f64) -> f64
Calculates the survival function for the gamma
distribution at x
§Formula
(1 / Γ(α)) * γ(α, β * x)
where α
is the shape, β
is the rate, Γ
is the gamma function,
and γ
is the upper incomplete gamma function
Source§fn inverse_cdf(&self, p: f64) -> f64
fn inverse_cdf(&self, p: f64) -> f64
cdf
to obtain an approximation
of F^-1(p) := inf { x | F(x) >= p }
. Needless to say, performance may
may be lacking.Source§impl Distribution<f64> for Gamma
Available on crate feature rand
only.
impl Distribution<f64> for Gamma
rand
only.Source§impl Distribution<f64> for Gamma
impl Distribution<f64> for Gamma
Source§fn variance(&self) -> Option<f64>
fn variance(&self) -> Option<f64>
Returns the variance of the gamma distribution
§Formula
α / β^2
where α
is the shape and β
is the rate
Source§fn entropy(&self) -> Option<f64>
fn entropy(&self) -> Option<f64>
Returns the entropy of the gamma distribution
§Formula
α - ln(β) + ln(Γ(α)) + (1 - α) * ψ(α)
where α
is the shape, β
is the rate, Γ
is the gamma function,
and ψ
is the digamma function
impl Copy for Gamma
impl StructuralPartialEq for Gamma
Auto Trait Implementations§
impl Freeze for Gamma
impl RefUnwindSafe for Gamma
impl Send for Gamma
impl Sync for Gamma
impl Unpin for Gamma
impl UnwindSafe for Gamma
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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.