scipy.special.betaln#

scipy.special.betaln(a, b, out=None) = <ufunc 'betaln'>#

Natural logarithm of absolute value of beta function.

Computes ln(abs(beta(a, b))).

Parameters:
a, barray_like

Positive, real-valued parameters

outndarray, optional

Optional output array for function values

Returns:
scalar or ndarray

Value of the betaln function

See also

gamma

the gamma function

betainc

the regularized incomplete beta function

beta

the beta function

Notes

Array API Standard Support

betaln has 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 none of the other ufunc kwargs. out is 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. out is never supported for JAX because JAX arrays are immutable. betaln does not currently support out for the PyTorch backend.

See Support for the array API standard for more information.

Examples

>>> import numpy as np
>>> from scipy.special import betaln, beta

Verify that, for moderate values of a and b, betaln(a, b) is the same as log(beta(a, b)):

>>> betaln(3, 4)
-4.0943445622221
>>> np.log(beta(3, 4))
-4.0943445622221

In the following beta(a, b) underflows to 0, so we can’t compute the logarithm of the actual value.

>>> a = 400
>>> b = 900
>>> beta(a, b)
0.0

We can compute the logarithm of beta(a, b) by using betaln:

>>> betaln(a, b)
-804.3069951764146