Special Functions Library

The Special Functions Library is a collection of the most frequently used mathematical special functions such as factorial or Gamma function.

List of frequently used mathematical special functions

  1. Beta Function

  2. Binomial Coefficient

  3. Error Function

  4. Factorial

  5. Gamma Function

  6. Incomplete Beta Function

  7. Incomplete Gamma Function

Table 20.42. Table of methods for special functions

FunctionMethodDescription
Beta functionbeta(double a, double b)returns the value of the beta function B(a,b)
Binomial coefficientbinomialCoefficient(int n, int k)returns the value of the binomial coefficient n!/(k!(n-k)!)
Error functionerror(double x)returns the value of the error function Erf(x)
Factorialfactorial(int n)returns the value of the factorial n!
Gamma functiongamma(double a)returns the value of the gamma function Γ(a)
Incomplete beta functionincompleteBeta(double a, double b; double x)returns the value of the ratio B(x;a,b)/B(a,b), where B(x;a,b) - incomplete beta function
Incomplete gamma functionincompleteGamma(double a, double x)returns the value of the ratio Γ(a,x)/Γ(a), where Γ(a,x) - incomplete gamma function
Logarithm of the beta functionlogBeta(double a, double b)returns the natural logarithm of the beta function value B(a,b)
Logarithm of the factoriallogFactorial(int n)returns the natural logarithm of the factorial n!
Logarithm of the gamma functionlogGamma(double a)returns the natural logarithm of the gamma function value Γ(a)

Example 20.5. Using distributions library (special functions)

from biz.sc.math.distributions import * 

_sf = SpecialFunctions()

print 'Factorial:',_sf.factorial(10)
print 'Beta:',_sf.beta(3,4)
print 'Incomplete Beta',_sf.incompleteBeta(3,4,0.5)

Output:

Factorial: 3628800.0
Beta: 0.01666666666666636
Incomplete Beta 0.010937499999999692