prfmodel.density.shifted_gamma_density

prfmodel.density.shifted_gamma_density(value: prfmodel.typing.Tensor, shape: prfmodel.typing.Tensor, rate: prfmodel.typing.Tensor, shift: prfmodel.typing.Tensor, norm: bool = True) prfmodel.typing.Tensor

Calculate the density of a shifted gamma distribution.

The gamma distribution is shifted by shift and padded with zeros if necessary.

Parameters:
  • value (prfmodel.typing.Tensor) – The values at which to evaluate the shifted gamma distribution. Must be scalar or with shape (1, m).

  • shape (prfmodel.typing.Tensor) – The shape parameter. Must be > 0 and scalar or with shape (n, 1).

  • rate (prfmodel.typing.Tensor) – The rate parameter. Must be > 0 and scalar or with shape (n, 1).

  • shift (prfmodel.typing.Tensor) – The shift parameter. When > 0, shifts the distribution to the right.

  • norm (bool, default=True) – Whether to compute the normalized density.

Returns:

The density of the shifted gamma distribution at value as a scalar or with shape (n, m). The density for shifted values that are zero or lower is zero.

Return type:

prfmodel.typing.Tensor

See also

gamma_density

The (unshifted) gamma distribution density.

Examples

>>> import numpy as np
>>> from prfmodel.density import shifted_gamma_density
>>> t = np.array([[1.0, 2.0, 3.0]])   # shape (1, 3)
>>> shape = np.array([[2.0], [4.0]])   # shape (2, 1)
>>> rate = np.array([[1.0], [1.0]])    # shape (2, 1)
>>> shift = np.array([[0.5], [0.0]])   # shape (2, 1)
>>> dens = shifted_gamma_density(t, shape, rate, shift)
>>> print(dens.shape)
(2, 3)