Skip to content
fn

psi

→Tensor
psi(input: Tensor)

Digamma function ψ(x)=ddxlog⁡Γ(x)\psi(x) = \frac{d}{dx} \log \Gamma(x).

Convenience alias for lucid.digamma. The digamma function is the logarithmic derivative of the gamma function and the fundamental building block of the polygamma family.

Parameters

inputTensor
Input tensor; any floating-point dtype.

Returns

Tensor

ψ(x)\psi(x) element-wise.

Notes

Definition:

ψ(x)=ddxlog⁡Γ(x)=Γ′(x)Γ(x)=−γ+∑k=0∞(1k+1−1k+x),\psi(x) = \frac{d}{dx} \log \Gamma(x) = \frac{\Gamma'(x)}{\Gamma(x)} = -\gamma + \sum_{k=0}^\infty \left(\frac{1}{k + 1} - \frac{1}{k + x}\right),

where γ≈0.5772\gamma \approx 0.5772 is the Euler–Mascheroni constant. Used in the derivatives of log-likelihoods of the Gamma / Beta / Dirichlet distributions. Has simple poles at the non-positive integers.

Examples

>>> import lucid
>>> from lucid.special import psi
>>> psi(lucid.tensor([1.0, 2.0, 10.0]))
tensor([-0.5772, 0.4228, 2.252])