PHP Class MathPHP\Functions\Special

Datei anzeigen Open project: markrogoyski/math-php Class Usage Examples

Public Methods

Method Description
beta ( integer $x, integer $y ) : float Beta function
complementaryErrorFunction ( number $x ) : number Complementary error function (erfc) erfc(x) ≡ 1 - erf(x)
confluentHypergeometric ( number $a, number $b, number $z ) : number Confluent Hypergeometric Function
erf ( number $x ) : number Error function (Gauss error function) Convenience method for errorFunction
erfc ( number $x ) : number Complementary error function (erfc) Convenience method for complementaryErrorFunction
errorFunction ( number $x ) : number Error function (Gauss error function) https://en.wikipedia.org/wiki/Error_function
gamma ( number $n ) : number Gamma function https://en.wikipedia.org/wiki/Gamma_function https://en.wikipedia.org/wiki/Particular_values_of_the_Gamma_function
gammaLanczos ( number $z ) : number Gamma function - Lanczos' approximation https://en.wikipedia.org/wiki/Gamma_function https://en.wikipedia.org/wiki/Lanczos_approximation
gammaStirling ( number $n ) : number Gamma function - Stirling approximation https://en.wikipedia.org/wiki/Gamma_function https://en.wikipedia.org/wiki/Stirling%27s_approximation https://www.wolframalpha.com/input/?i=Gamma(n)&lk=3
generalizedHypergeometric ( integer $p, integer $q, variadic $params ) : number Generalized Hypergeometric Function
hypergeometric ( number $a, number $b, number $c, number $z ) : number Hypergeometric Function
incompleteBeta ( $x, $a, $b ) : number Incomplete Beta Function - B(x;a,b)
logistic ( number $x₀, number $L, number $k, number $x ) : float Logistic function (logistic sigmoid function) A logistic function or logistic curve is a common "S" shape (sigmoid curve).
lowerIncompleteGamma ( $s, $x ) : number Lower incomplete gamma function - γ(s, t) https://en.wikipedia.org/wiki/Incomplete_gamma_function#Lower_incomplete_Gamma_function
regularizedIncompleteBeta ( $x, $a, $b ) : number Regularized incomplete beta function - Iₓ(a, b)
sgn ( float $x ) : integer Sign function (signum function) - sgn Convenience wrapper for signum function.
sigmoid ( number $t ) : float Sigmoid function A sigmoid function is a mathematical function having an "S" shaped curve (sigmoid curve).
signum ( float $x ) : integer Sign function (signum function) - sgn Extracts the sign of a real number.
softmax ( array $𝐳 ) : array Softmax (normalized exponential) A generalization of the logistic function that "squashes" a K-dimensional vector z of arbitrary real values to a K-dimensional vector σ(z) of real values in the range (0, 1) that add up to 1.
upperIncompleteGamma ( number $s, number $x ) : number Upper Incomplete Gamma Function - Γ(s,x) https://en.wikipedia.org/wiki/Incomplete_gamma_function
Γ ( number $n ) : number Gamma function convenience method
γ ( $s, $x ) : number γ - Convenience method for lower incomplete gamma function https://en.wikipedia.org/wiki/Incomplete_gamma_function#Lower_incomplete_Gamma_function

Private Methods

Method Description
iBetaCF ( integer $m, $x, $a, $b ) : number Regularized incomplete beta function - Iₓ(a, b)

Method Details

beta() public static method

https://en.wikipedia.org/wiki/Beta_function Γ(x)Γ(y) B(x, y) = -------- Γ(x + y)
public static beta ( integer $x, integer $y ) : float
$x integer
$y integer
return float

complementaryErrorFunction() public static method

Complementary error function (erfc) erfc(x) ≡ 1 - erf(x)
public static complementaryErrorFunction ( number $x ) : number
$x number
return number

confluentHypergeometric() public static method

https://en.wikipedia.org/wiki/Confluent_hypergeometric_function ∞ ____ \ a⁽ⁿ⁾ * zⁿ ₁F₁ = > --------- b⁽ⁿ⁾ * n! ‾‾‾‾ n=0
public static confluentHypergeometric ( number $a, number $b, number $z ) : number
$a number the numerator value
$b number the denominator value
$z number
return number

erf() public static method

Error function (Gauss error function) Convenience method for errorFunction
public static erf ( number $x ) : number
$x number
return number

erfc() public static method

Complementary error function (erfc) Convenience method for complementaryErrorFunction
public static erfc ( number $x ) : number
$x number
return number

errorFunction() public static method

This is an approximation of the error function (maximum error: 1.5×10−7) erf(x) ≈ 1 - (a₁t + a₂t² + a₃t³ + a₄t⁴ + a₅t⁵)ℯ^-x² 1 t = ------ 1 + px p = 0.3275911 a₁ = 0.254829592, a₂ = −0.284496736, a₃ = 1.421413741, a₄ = −1.453152027, a₅ = 1.061405429
public static errorFunction ( number $x ) : number
$x number
return number

gamma() public static method

For postive integers: Γ(n) = (n - 1)! For half integers: _ (2n)! Γ(½ + n) = √π ------- 4ⁿ n! For real numbers: use Lanczos approximation
public static gamma ( number $n ) : number
$n number
return number

gammaLanczos() public static method

For postive integers: Γ(n) = (n - 1)! If z is < 0.5, use reflection formula: π Γ(1 - z)Γ(z) = ------ sin πz therefore: π Γ(z) = ----------------- sin πz * Γ(1 - z) otherwise: __ / 1 \ z+½ Γ(z + 1) = √2π | z + g + - | e^-(z+g+½) A(z) \ 2 / use pre-computed p coefficients: g = 7, n = 9
public static gammaLanczos ( number $z ) : number
$z number
return number

gammaStirling() public static method

For postive integers: Γ(n) = (n - 1)! For positive real numbers -- approximation: ___ __ / 1 / 1 \ n Γ(n)≈ √2π ℯ⁻ⁿ / - | n + ----------- | √ n \ 12n - 1/10n /
public static gammaStirling ( number $n ) : number
$n number
return number

generalizedHypergeometric() public static method

https://en.wikipedia.org/wiki/Generalized_hypergeometric_function ∞ ____ \ ∏ap⁽ⁿ⁾ * zⁿ pFq(a₁,a₂,...ap;b₁,b₂,...,bq;z)= > ------------ ∏bq⁽ⁿ⁾ * n! ‾‾‾‾ n=0 Where a⁽ⁿ⁾ is the Pochhammer Function or Rising Factorial We are evaluating this as a series: (a + n - 1) * z ∏n = ∏n₋₁ * ----------------- (b + n - 1) * n n (a + n - 1) * z ₁F₁ = ₁F₁n₋₁ + ∏ ----------------- = ₁F₁n₋₁ + ∏n 1 (b + n - 1) * n
public static generalizedHypergeometric ( integer $p, integer $q, variadic $params ) : number
$p integer the number of parameters in the numerator
$q integer the number of parameters in the denominator
$params variadic a collection of the a, b, and z parameters
return number

hypergeometric() public static method

https://en.wikipedia.org/wiki/Hypergeometric_function ∞ ____ \ a⁽ⁿ⁾ * b⁽ⁿ⁾ * zⁿ ₂F₁ = > ---------------- c⁽ⁿ⁾ * n! ‾‾‾‾ n=0
public static hypergeometric ( number $a, number $b, number $c, number $z ) : number
$a number the first numerator value
$b number the second numerator value
$c number the denominator value
$z number |z| < 1
return number

incompleteBeta() public static method

Generalized form of the beta function https://en.wikipedia.org/wiki/Beta_function#Incomplete_beta_function
public static incompleteBeta ( $x, $a, $b ) : number
$x Upper limit of the integration 0 ≦ x ≦ 1
$a Shape parameter a > 0
$b Shape parameter b > 0
return number

logistic() public static method

https://en.wikipedia.org/wiki/Logistic_function L f(x) = ----------- 1 + ℯ⁻ᵏ⁽ˣ⁻ˣ⁰⁾
public static logistic ( number $x₀, number $L, number $k, number $x ) : float
$x₀ number x-value of the sigmoid's midpoint
$L number the curve's maximum value
$k number the steepness of the curve
$x number
return float

lowerIncompleteGamma() public static method

This function is exact for all integer multiples of .5 using the recurrance relation: γ⟮s+1,x⟯= s*γ⟮s,x⟯-xˢ*eˣ The function can be evaluated at other points using the series: zˢ / x x² x³ \ γ(s,x) = -------- | 1 + ----- + ---------- + --------------- + ... | s * eˣ \ s+1 (s+1)(s+2) (s+1)(s+2)(s+3) /
public static lowerIncompleteGamma ( $s, $x ) : number
$s
$x
return number

regularizedIncompleteBeta() public static method

https://en.wikipedia.org/wiki/Beta_function#Incomplete_beta_function This function looks at the values of x, a, and b, and determines which algorithm is best to calculate the value of Iₓ(a, b) http://www.boost.org/doc/libs/1_35_0/libs/math/doc/sf_and_dist/html/math_toolkit/special/sf_beta/ibeta_function.html https://github.com/boostorg/math/blob/develop/include/boost/math/special_functions/beta.hpp
public static regularizedIncompleteBeta ( $x, $a, $b ) : number
$x Upper limit of the integration 0 ≦ x ≦ 1
$a Shape parameter a > 0
$b Shape parameter b > 0
return number

sgn() public static method

Sign function (signum function) - sgn Convenience wrapper for signum function.
public static sgn ( float $x ) : integer
$x float
return integer

sigmoid() public static method

Often, sigmoid function refers to the special case of the logistic function https://en.wikipedia.org/wiki/Sigmoid_function 1 S(t) = ------- 1 + ℯ⁻ᵗ
public static sigmoid ( number $t ) : float
$t number
return float

signum() public static method

https://en.wikipedia.org/wiki/Sign_function { -1 if x < 0 sgn(x) = { 0 if x = 0 { 1 if x > 0
public static signum ( float $x ) : integer
$x float
return integer

softmax() public static method

https://en.wikipedia.org/wiki/Softmax_function ℯᶻⱼ σ(𝐳)ⱼ = ------ for j = 1 to K ᴷ ∑ ℯᶻᵢ ⁱ⁼¹
public static softmax ( array $𝐳 ) : array
$𝐳 array
return array

upperIncompleteGamma() public static method

Upper Incomplete Gamma Function - Γ(s,x) https://en.wikipedia.org/wiki/Incomplete_gamma_function
public static upperIncompleteGamma ( number $s, number $x ) : number
$s number shape parameter > 0
$x number lower limit of integration
return number

Γ() public static method

Gamma function convenience method
public static Γ ( number $n ) : number
$n number
return number

γ() public static method

γ - Convenience method for lower incomplete gamma function https://en.wikipedia.org/wiki/Incomplete_gamma_function#Lower_incomplete_Gamma_function
public static γ ( $s, $x ) : number
$s
$x
return number