gluonts.mx.model.tpp.distribution.base module#

class gluonts.mx.model.tpp.distribution.base.TPPDistribution[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

Distribution used in temporal point processes.

This class must implement new methods log_intensity, log_survival that are necessary for computing log-likelihood of TPP realizations. Also, sample_conditional is necessary for sampling TPPs.

arg_names: Tuple#
cdf(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Return the value of the cumulative distribution function evaluated at x.

log_intensity(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Logarithm of the intensity (a.k.a. hazard) function.

The intensity is defined as \(\lambda(x) = p(x) / S(x)\).

log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

Tensor of shape batch_shape containing the log-density of the distribution for each event in x.

Return type

Tensor

log_survival(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Logarithm of the survival function log S(x) = log(1 - CDF(x)).

sample(num_samples=None, dtype=<class 'numpy.float32'>, lower_bound: typing.Optional[typing.Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

class gluonts.mx.model.tpp.distribution.base.TPPDistributionOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

Class to construct a distribution given the output of a network.

Two differences compared to the base class DistributionOutput: 1. Location param cannot be specified (all distributions must start at 0). 2. The return type is either TPPDistribution or TPPTransformedDistribution.

args_dim: Dict[str, int]#
distr_cls: type#
distribution(distr_args, loc=None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) Union[gluonts.mx.model.tpp.distribution.base.TPPDistribution, gluonts.mx.model.tpp.distribution.base.TPPTransformedDistribution][source]#

Construct the associated distribution, given the collection of constructor arguments and, optionally, a scale tensor.

Parameters
  • distr_args – Constructor arguments for the underlying TPPDistribution type.

  • loc – Location parameter, specified here for compatibility with the superclass. Should never be specified.

  • scale – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.

class gluonts.mx.model.tpp.distribution.base.TPPTransformedDistribution(base_distribution: gluonts.mx.model.tpp.distribution.base.TPPDistribution, transforms: List[gluonts.mx.distribution.bijection.Bijection])[source]#

Bases: gluonts.mx.distribution.transformed_distribution.TransformedDistribution

TransformedDistribution used in temporal point processes.

This class must implement new methods log_intensity, log_survival that are necessary for computing log-likelihood of TPP realizations. Also, sample_conditional is necessary for sampling TPPs.

Additionally, the sequence of transformations passed to the constructor must be increasing.

arg_names: Tuple#
base_distribution: gluonts.mx.model.tpp.distribution.base.TPPDistribution#
cdf(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Return the value of the cumulative distribution function evaluated at x.

log_intensity(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Logarithm of the intensity (a.k.a. hazard) function.

The intensity is defined as \(\lambda(y) = p(y) / S(y)\).

log_survival(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Logarithm of the survival function.

\(\log S(y) = \log(1 - CDF(y))\)

sample(num_samples=None, dtype=<class 'numpy.float32'>, lower_bound: typing.Optional[typing.Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Draw samples from the distribution.

Parameters
  • num_samples – Number of samples to generate.

  • dtype – Data type of the generated samples.

  • lower_bound – If None, generate samples as usual. If lower_bound is provided, all generated samples will be larger than the specified values. That is, we sample from p(x | x > lower_bound). Shape: (*batch_size)

Returns

Transformed samples drawn from the base distribution. Shape: (num_samples, *batch_size)

Return type

x