Gamma

Trait Gamma 

Source
pub trait Gamma
where Self: Sized,
{ // Required methods fn gamma(self) -> Self; fn digamma(self) -> Self; fn trigamma(&self) -> Self; fn inc_gamma(self, p: Self) -> Self; fn ln_gamma(self) -> (Self, i32); }
Expand description

Gamma functions.

Required Methods§

Source

fn gamma(self) -> Self

Compute the gamma function.

Source

fn digamma(self) -> Self

Compute the real-valued digamma function.

The formula is as follows:

       d ln(Γ(p))
ψ(p) = ----------
           dp

where Γ is the gamma function. The computation is based on an approximation as described in the reference below.

§Examples
use special::Gamma;

const EULER_MASCHERONI: f64 = 0.57721566490153286060651209008240243104215933593992;
assert!((1.0.digamma() + EULER_MASCHERONI).abs() < 1e-15);
§References
  1. M. J. Beal, Variational algorithms for approximate Bayesian inference. University of London, 2003, pp. 265–266.
Source

fn trigamma(&self) -> Self

Compute the trigamma function.

The implementation is based on a Julia implementation.

Source

fn inc_gamma(self, p: Self) -> Self

Compute the regularized lower incomplete gamma function.

The formula is as follows:

          γ(x, p)    1   x
P(x, p) = ------- = ---- ∫ t^(p - 1) e^(-t) dt
           Γ(p)     Γ(p) 0

where γ is the incomplete lower gamma function, and Γ is the complete gamma function.

The implementation is based on a C implementation by John Burkardt. The original algorithm was published in Applied Statistics and is known as Algorithm AS 239.

Source

fn ln_gamma(self) -> (Self, i32)

Compute the natural logarithm of the gamma function.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl Gamma for f32

Source§

fn gamma(self) -> Self

Source§

fn digamma(self) -> Self

Source§

fn trigamma(&self) -> Self

Source§

fn inc_gamma(self, p: Self) -> Self

Source§

fn ln_gamma(self) -> (Self, i32)

Source§

impl Gamma for f64

Source§

fn gamma(self) -> Self

Source§

fn digamma(self) -> Self

Source§

fn trigamma(&self) -> Self

Source§

fn inc_gamma(self, p: Self) -> Self

Source§

fn ln_gamma(self) -> (Self, i32)

Implementors§