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
Beta Function
Binomial Coefficient
Error Function
Factorial
Gamma Function
Incomplete Beta Function
Incomplete Gamma Function
Table 20.42. Table of methods for special functions
Function | Method | Description |
Beta function | beta(double a, double b) | returns the value of the beta function B(a,b) |
Binomial coefficient | binomialCoefficient(int n, int k) | returns the value of the binomial coefficient n!/(k!(n-k)!) |
Error function | error(double x) | returns the value of the error function Erf(x) |
Factorial | factorial(int n) | returns the value of the factorial n! |
Gamma function | gamma(double a) | returns the value of the gamma function Γ(a) |
Incomplete beta function | incompleteBeta(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 function | incompleteGamma(double a, double x) | returns the value of the ratio Γ(a,x)/Γ(a), where Γ(a,x) - incomplete gamma function |
Logarithm of the beta function | logBeta(double a, double b) | returns the natural logarithm of the beta function value B(a,b) |
Logarithm of the factorial | logFactorial(int n) | returns the natural logarithm of the factorial n! |
Logarithm of the gamma function | logGamma(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