•special — Special functions
•special name returns the special function called name, as SciPy names it, with SciPy's order of arguments. For a list of names, •special returns a list of functions.
[erf gammaln]←•special "erf" "gammaln"
erf 0.5 ⍝ 0.5204998778
gammaln 5 ⍝ 3.17805383
Each function works item by item on real numbers and gives floats, as ⊛ does. Exact numbers and integers are converted to floats.
| Name | Call | Result |
|---|---|---|
"gammaln" | gammaln x | ln |Γ(x)| |
"digamma" | digamma x | ψ(x), the derivative of ln Γ(x) |
"polygamma" | n polygamma x | ψ⁽ⁿ⁾(x), the nth derivative of ψ, for a whole n |
"erf" | erf x | the error function |
"erfc" | erfc x | 1 − erf x, without the loss of digits for large x |
"erfinv" | erfinv p | the x with erf x = p |
"beta" | a beta b | B(a, b) = Γ(a) Γ(b) ÷ Γ(a + b) |
"gammainc" | a gammainc x | the regularized lower incomplete gamma function P(a, x) |
"betainc" | [a b] betainc x | the regularized incomplete beta function Iₓ(a, b) |
betainc takes its shape parameters a and b as one pair on the left. For arrays of pairs, apply it with Rank, which pairs each row of the left argument with an item of the right.
[pg bi]←•special "polygamma" "betainc"
1 pg 1 ⍝ 1.644934067
[2 3] bi 0.5 ⍝ 0.6875
[2 3◇4 5] bi¹ ⁰ 0.5 0.25 ⍝ 0.6875 0.1138153076
∂ differentiates each function with respect to its last argument. The slope of gammaln is digamma, the slope of digamma is 1 polygamma, and the slope of n polygamma is (n+1) polygamma. ∂ also differentiates beta with respect to a. ∂ raises UNSUPPORTED for a slope with respect to the order of polygamma, the a of gammainc or the pair of betainc:
[erf bi]←•special "erf" "betainc"
erf∂ 0.5 ⍝ 0.8787825789
{[2 3] bi ω}∂ 0.5 ⍝ 1.5
0 polygamma x is digamma. For a whole n from 1 to 170, n polygamma x has a result for any x above 0. A result too large for its float kind is ∞ or ¯∞, as 170 polygamma 0.5 is.
An unknown name, a name that isn't a string or a complex argument raises DOMAIN. A call with the wrong number of arguments raises SYNTAX. A left argument of betainc that isn't one pair raises LENGTH.
Under dynamic kinds, digamma, polygamma, erfinv, beta, gammainc and betainc raise DOMAIN when non-NaN arguments produce NaN. This includes digamma at a negative integer and incomplete beta outside its domain. Under static kinds, these numeric checks are disabled and NaN is returned. Infinite results do not raise an error.