fn
polygamma
→Tensorpolygamma(n: int, x: Tensor)Polygamma function .
The n-th derivative of the digamma function. Polygamma
functions appear in the derivatives of log-partition functions of
the Gamma / Beta / Dirichlet families and are needed for evaluating
Fisher information matrices for these distributions analytically.
Parameters
nintNon-negative integer order. Only
are supported;
n = 0 recovers lucid.digamma,
n = 1 is the trigamma function. Higher orders raise
NotImplementedError.xTensorReal argument; any floating-point dtype.
Returns
Tensor element-wise, same shape and dtype as
x.
Notes
Definition (for n >= 1):
Implementation: shift x upward by using the
recurrence
accumulate the per-step corrections, then evaluate the Bernoulli asymptotic series at the shifted argument where it is well-conditioned. Accuracy is roughly seven decimal digits across the positive-real regime.
Raises ValueError for n < 0 and NotImplementedError for
n >= 4.
Examples
>>> import lucid
>>> from lucid.special import polygamma
>>> polygamma(1, lucid.tensor([1.0, 2.0, 5.0]))
Tensor([1.6449, 0.6449, 0.2213])