module Alea::Core

Included Modules

Defined in:

alea/core/cgam.cr
alea/core/cgen.cr
alea/core/clim.cr
alea/core/cpois.cr
alea/core/czig.cr

Constant Summary

SPECFUN_EPS32 = 1.0e-06

Single precision tolerance

SPECFUN_EPS64 = 1.0e-15

Double precision tolerance

SPECFUN_ITMAX = 1000

Iteration limit within which Alea::NoConvergeError is not raised

Class Method Summary

Class Method Detail

def self.inc_gamma(a, x, uorl) #

Estimate the Incomplete Gamma Function

When x > (a+1), the upper gamma function can be evaluated as

                -x    a
               e   * x
  G(a,x) ~= --------------
               cf(a,x)

where cf(a,x) is the continued fraction defined above, its coefficients a(i) and b(i) are implemented in #inc_gamma_ctdfr_proc.

When x < (a+1), it is more convenient to apply the following Taylor series that evaluates the lower incomplete gamma function:

                         inf
                        -----
             -x    a    \        G(a)       i
  g(a,x) ~= e   * x  *   >    ---------- * x
                        /      G(a+1+i)
                        -----
                         i=0

Applying the following property of the gamma function:

  G(a+1) = a * G(a)

The Taylor series above can be further simplified to:

                         inf
                        -----              i
             -x    a    \                 x
  g(a,x) ~= e   * x  *   >    -------------------------
                        /      a * (a+1) * ... * (a+i)
                        -----
                         i=0

Once either a lower or an upper incomplete gamma function is evaluated, the other value may be quickly obtained by applying the following property of the incomplete gamma function:

  G(a,x) + g(a,x) = G(a)

@parameters:

  • a: parameter of the Incomplete Gamma function.
  • x: the upper integration limit.
  • uorl: symbol to request the :upper or :lower inc. gamma function.

@exceptions:


[View source]
def self.inc_gamma_regular(a, x, uorl) #

Estimate the Incomplete Regularized Gamma function.

@parameters:

  • a: parameter of the Incomplete Gamma function.
  • x: the upper integration limit.
  • uorl: symbol to request the :upper or :lower inc. reg. gamma function.

@references:

@exceptions:


[View source]
def self.incg_regular_lower(a, x) #

Estimate the Incomplete Regular Lower Gamma function.

@parameters:

  • a: parameter of the Incomplete Gamma function.
  • x: the upper integration limit.

@references:

@exceptions:


[View source]
def self.incg_regular_upper(a, x) #

Estimate the Incomplete Regular Upper Gamma function.

@parameters:

  • a: parameter of the Incomplete Gamma function.
  • x: the upper integration limit.

@references:

@exceptions:


[View source]
def self.poisson_mult(lam : Float | Int, prng : Alea::PRNG) #

Ok here to pass the prng: it's a reference and it will not affect repeatability.


[View source]
def self.poisson_ptrs(lam : Float | Int, prng : Alea::PRNG) #

Ok here to pass the prng: it's a reference and it will not affect repeatability.


[View source]