scipy.special.digammainv#

scipy.special.digammainv(y, out=None) = <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\).

See also

psi

The digamma function.

digamma

Alias for psi.

Notes

Added in version 1.19.0.

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()
../../_images/scipy-special-digammainv-1.png