scipy.special.beta#
- scipy.special.beta(a, b, out=None) = <wrapped_ufunc 'beta'>#
Beta function.
This function is defined in [1] as
\[B(a, b) = \int_0^1 t^{a-1}(1-t)^{b-1}dt = \frac{\Gamma(a)\Gamma(b)}{\Gamma(a+b)},\]where \(\Gamma\) is the gamma function.
- Parameters:
- a, barray_like
Real-valued arguments
- outndarray, optional
Optional output array for the function result
- Returns:
- scalar or ndarray
Value of the beta function
See also
Notes
Array API Standard Support
betahas support for Python Array API Standard compatible backends in addition to NumPy. The following combinations of backend and device (or other capability) are supported.Library
CPU
GPU
NumPy
✅
n/a
CuPy
n/a
✅
PyTorch
✅
⛔
JAX
✅
✅
Dask
✅
n/a
For the NumPy backend, this function supports all NumPy ufunc keyword arguments. Other backends may support
out, but typically none of the other ufunc kwargs.outis typically supported for CuPy and PyTorch, but not currently in cases where SciPy relies on a generic Array API implementation or, for PyTorch on CPU, falls back to the NumPy backend.outis never supported for JAX because JAX arrays are immutable.betadoes not currently supportoutfor the PyTorch backend.See Array API coverage for more information.
References
[1]NIST Digital Library of Mathematical Functions, Eq. 5.12.1. https://dlmf.nist.gov/5.12
Examples
>>> import scipy.special as sc
The beta function relates to the gamma function by the definition given above:
>>> sc.beta(2, 3) 0.08333333333333333 >>> sc.gamma(2)*sc.gamma(3)/sc.gamma(2 + 3) 0.08333333333333333
As this relationship demonstrates, the beta function is symmetric:
>>> sc.beta(1.7, 2.4) 0.16567527689031739 >>> sc.beta(2.4, 1.7) 0.16567527689031739
This function satisfies \(B(1, b) = 1/b\):
>>> sc.beta(1, 4) 0.25