Functions | Variables
vnl_gamma.cxx File Reference

Complete and incomplete gamma function approximations. More...

#include <iostream>
#include <cassert>
#include "vnl_gamma.h"

Go to the source code of this file.

Functions

double vnl_log_gamma (double x)
 Approximate gamma function. More...
 
double vnl_gamma_p (double a, double x)
 Normalised Incomplete gamma function, P(a,x). More...
 
double vnl_gamma_q (double a, double x)
 Normalised Incomplete gamma function, Q(a,x). More...
 
double vnl_digamma (double z)
 approximate digamma function, dLog[gamma[z]]/dz. More...
 

Variables

constexpr int MAX_ITS = 100
 
const double MaxRelError = 3.0e-7
 
const double vnl_very_small = 1.0e-30
 

Detailed Description

Complete and incomplete gamma function approximations.

Author
Tim Cootes

Definition in file vnl_gamma.cxx.

Function Documentation

◆ vnl_digamma()

double vnl_digamma ( double  x)

approximate digamma function, dLog[gamma[z]]/dz.

Analytic derivative of the Lanczos approximation. Error < 10^-11 1<z<20.

Definition at line 114 of file vnl_gamma.cxx.

◆ vnl_gamma_p()

double vnl_gamma_p ( double  a,
double  x 
)

Normalised Incomplete gamma function, P(a,x).

$P(a,x)=\frac{1}{\Gamma(a)}\int_0^x e^{-t}t^{a-1}dt$ Note the order of parameters - this is the normal maths order. MATLAB uses gammainc(x,a), ie the other way around

Definition at line 92 of file vnl_gamma.cxx.

◆ vnl_gamma_q()

double vnl_gamma_q ( double  a,
double  x 
)

Normalised Incomplete gamma function, Q(a,x).

$Q(a,x)=\frac{1}{\Gamma(a)}\int_x^{\infty}e^{-t}t^{a-1}dt$

Definition at line 103 of file vnl_gamma.cxx.

◆ vnl_log_gamma()

double vnl_log_gamma ( double  x)

Approximate gamma function.

Approximate log of gamma function.

Uses 6 parameter Lanczos approximation as described by Viktor Toth (http://www.rskey.org/gamma.htm) Accurate to about 3e-11.

Definition at line 18 of file vnl_gamma.cxx.

Variable Documentation

◆ MAX_ITS

constexpr int MAX_ITS = 100

Definition at line 32 of file vnl_gamma.cxx.

◆ MaxRelError

const double MaxRelError = 3.0e-7

Definition at line 33 of file vnl_gamma.cxx.

◆ vnl_very_small

const double vnl_very_small = 1.0e-30

Definition at line 34 of file vnl_gamma.cxx.