Special functions (scipy.special)#
Almost all of the functions below accept NumPy arrays as input arguments as well as single numbers. This means they follow broadcasting and automatic array-looping rules. Technically, they are NumPy universal functions. Functions which do not accept NumPy arrays are marked by a warning in the section description.
See also
scipy.special.cython_special – Typed Cython versions of special functions
Error handling#
Errors are handled by returning NaNs or other appropriate values. Some of the special function routines can emit warnings or raise exceptions when an error occurs. By default this is disabled, except for memory allocation errors, which result in an exception being raised. To query and control the current error handling state the following functions are provided.
|
Get the current way of handling special-function errors. |
|
Set how special-function errors are handled. |
|
Context manager for special-function error handling. |
Warning that can be emitted by special functions. |
|
Exception that can be raised by special functions. |
Available functions#
Airy functions#
Elliptic functions and integrals#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Bessel functions#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following function does not accept NumPy arrays (it is not a universal function):
|
Jahnke-Emden Lambda function, Lambdav(x). |
Zeros of Bessel functions#
The following functions do not accept NumPy arrays (they are not universal functions):
|
Compute zeros of integer-order Bessel functions Jn and Jn'. |
|
Compute nt zeros of Bessel functions Jn(x), Jn'(x), Yn(x), and Yn'(x). |
|
Compute zeros of integer-order Bessel functions Jn. |
|
Compute zeros of integer-order Bessel function derivatives Jn'. |
|
Compute zeros of integer-order Bessel function Yn(x). |
|
Compute zeros of integer-order Bessel function derivatives Yn'(x). |
|
Compute nt zeros of Bessel function Y0(z), and derivative at each zero. |
|
Compute nt zeros of Bessel function Y1(z), and derivative at each zero. |
|
Compute nt zeros of Bessel derivative Y1'(z), and value at each zero. |
Faster versions of common Bessel functions#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integrals of Bessel functions#
|
|
|
|
|
|
|
|
|
Derivatives of Bessel functions#
|
Compute derivatives of Bessel functions of the first kind. |
|
Compute derivatives of Bessel functions of the second kind. |
|
Compute derivatives of modified Bessel functions of the first kind. |
|
Compute derivatives of real-order modified Bessel function Kv(z) |
|
Compute derivatives of Hankel function H1v(z) with respect to z. |
|
Compute derivatives of Hankel function H2v(z) with respect to z. |
Spherical Bessel functions#
|
Spherical Bessel function of the first kind or its derivative. |
|
Spherical Bessel function of the second kind or its derivative. |
|
Modified spherical Bessel function of the first kind or its derivative. |
|
Modified spherical Bessel function of the second kind or its derivative. |
Riccati-Bessel functions#
The following functions do not accept NumPy arrays (they are not universal functions):
|
Compute Riccati-Bessel function of the first kind and its derivative. |
|
Compute Riccati-Bessel function of the second kind and its derivative. |
Struve functions#
|
|
|
|
|
|
|
|
|
Raw statistical functions#
See also
scipy.stats: Friendly versions of these functions.
Binomial distribution#
|
|
|
|
|
|
|
|
|
Beta distribution#
|
|
|
F distribution#
|
|
|
|
|
|
|
Gamma distribution#
|
|
|
|
|
|
|
|
|
Negative binomial distribution#
|
|
|
|
|
|
|
|
|
Noncentral F distribution#
|
|
|
|
|
|
|
|
|
Noncentral t distribution#
|
|
|
|
|
|
|
Normal distribution#
|
|
|
|
|
|
|
|
|
|
|
Poisson distribution#
|
|
|
|
|
|
|
Student t distribution#
|
|
|
|
|
Chi square distribution#
|
|
|
|
|
|
|
Non-central chi square distribution#
|
|
|
|
|
|
|
Kolmogorov distribution#
|
|
|
|
|
|
|
Box-Cox transformation#
|
|
|
|
|
|
|
Sigmoidal functions#
|
|
|
|
|
Miscellaneous#
|
|
|
Information Theory functions#
|
|
|
|
|
|
|
|
|
Error function and Fresnel integrals#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Compute nt complex zeros of sine and cosine Fresnel integrals S(z) and C(z). |
|
|
|
|
|
The following functions do not accept NumPy arrays (they are not universal functions):
|
Compute the first nt zero in the first quadrant, ordered by absolute value. |
|
Compute nt complex zeros of cosine Fresnel integral C(z). |
|
Compute nt complex zeros of sine Fresnel integral S(z). |
Legendre functions#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following functions are in the process of being deprecated in favor of the above, which provide a more flexible and consistent interface.
Ellipsoidal harmonics#
|
Ellipsoidal harmonic functions E^p_n(l) |
|
Ellipsoidal harmonic functions F^p_n(l) |
|
Ellipsoidal harmonic normalization constants gamma^p_n |
Orthogonal polynomials#
The following functions evaluate values of orthogonal polynomials:
|
Compute the generalized (associated) Laguerre polynomial of degree n and order k. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following functions compute roots and quadrature weights for orthogonal polynomials:
|
Gauss-Legendre quadrature. |
|
Gauss-Chebyshev (first kind) quadrature. |
|
Gauss-Chebyshev (second kind) quadrature. |
|
Gauss-Chebyshev (first kind) quadrature. |
|
Gauss-Chebyshev (second kind) quadrature. |
|
Gauss-Jacobi quadrature. |
|
Gauss-Laguerre quadrature. |
|
Gauss-generalized Laguerre quadrature. |
|
Gauss-Hermite (physicist's) quadrature. |
|
Gauss-Hermite (statistician's) quadrature. |
|
Gauss-Gegenbauer quadrature. |
|
Gauss-Legendre (shifted) quadrature. |
|
Gauss-Chebyshev (first kind, shifted) quadrature. |
|
Gauss-Chebyshev (second kind, shifted) quadrature. |
|
Gauss-Jacobi (shifted) quadrature. |
The functions below, in turn, return the polynomial coefficients in
orthopoly1d objects, which function similarly as numpy.poly1d.
The orthopoly1d class also has an attribute weights, which returns
the roots, weights, and total weights for the appropriate form of Gaussian
quadrature. These are returned in an n x 3 array with roots in the first
column, weights in the second column, and total weights in the final column.
Note that orthopoly1d objects are converted to poly1d when doing
arithmetic, and lose information of the original orthogonal polynomial.
|
Legendre polynomial. |
|
Chebyshev polynomial of the first kind. |
|
Chebyshev polynomial of the second kind. |
|
Chebyshev polynomial of the first kind on \([-2, 2]\). |
|
Chebyshev polynomial of the second kind on \([-2, 2]\). |
|
Jacobi polynomial. |
|
Laguerre polynomial. |
|
Generalized (associated) Laguerre polynomial. |
|
Physicist's Hermite polynomial. |
|
Normalized (probabilist's) Hermite polynomial. |
|
Gegenbauer (ultraspherical) polynomial. |
|
Shifted Legendre polynomial. |
|
Shifted Chebyshev polynomial of the first kind. |
|
Shifted Chebyshev polynomial of the second kind. |
|
Shifted Jacobi polynomial. |
Warning
Computing values of high-order polynomials (around order > 20) using
polynomial coefficients is numerically unstable. To evaluate polynomial
values, the eval_* functions should be used instead.
Hypergeometric functions#
|
|
|
|
|
|
|
Parabolic cylinder functions#
|
|
|
|
|
The following functions do not accept NumPy arrays (they are not universal functions):
Spheroidal wave functions#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Characteristic values for prolate spheroidal wave functions. |
|
Characteristic values for oblate spheroidal wave functions. |
The following functions require pre-computed characteristic value:
|
|
|
|
|
|
|
|
|
|
|
Kelvin functions#
|
|
|
Compute nt zeros of all Kelvin functions. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following functions do not accept NumPy arrays (they are not universal functions):
|
Compute nt zeros of the Kelvin function ber. |
|
Compute nt zeros of the Kelvin function bei. |
|
Compute nt zeros of the derivative of the Kelvin function ber. |
|
Compute nt zeros of the derivative of the Kelvin function bei. |
|
Compute nt zeros of the Kelvin function ker. |
|
Compute nt zeros of the Kelvin function kei. |
|
Compute nt zeros of the derivative of the Kelvin function ker. |
|
Compute nt zeros of the derivative of the Kelvin function kei. |
Combinatorics#
Other special functions#
|
|
|
Bernoulli numbers B0..Bn (inclusive). |
|
|
|
Periodic sinc function, also called the Dirichlet kernel. |
|
Euler numbers E(0), E(1), ..., E(n). |
|
|
|
|
|
|
|
The factorial of a number or array of numbers. |
|
Double factorial. |
|
Multifactorial of n of order k, n(!!...!). |
|
|
|
|
|
Compute the softmax function. |
|
Compute the logarithm of the softmax function. |
|
|
|
Riemann or Hurwitz zeta function. |
|
|
|
Compute the softplus function element-wise. |