scipy.special.digammainv#
- scipy.special.digammainv(y, out=None) = <wrapped_ufunc 'digammainv'>#
Inverse of the digamma function.
- Parameters:
- yarray_like of float
Real-valued argument.
- outndarray, optional
Optional output array for the function results.
- Returns:
- scalar or ndarray
Positive real solution of \(\psi(x) = y\).
Notes
Added in version 2.0.0.
Array API Standard Support
digammainvhas 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.digammainvdoes not currently supportoutfor the PyTorch backend.See Array API coverage for more information.
Examples
>>> import numpy as np >>> import matplotlib.pyplot as plt >>> from scipy.special import digamma, digammainv >>> x = np.logspace(-2, 2, 5) >>> np.allclose(digammainv(digamma(x)), x) True
Plot the digamma function and its inverse:
>>> x = np.linspace(0.3, 5, 200) >>> y = digamma(x) >>> t = np.linspace(-3, 4, 200) >>> fig, ax = plt.subplots() >>> ax.plot(x, y, label=r"$\psi(x)$") >>> ax.plot(y, digammainv(y), label=r"$\psi^{-1}(y)$") >>> ax.plot(t, t, "--", label=r"$y = x$") >>> ax.set_xlabel("input") >>> ax.legend() >>> plt.show()