gluonts.mx.model.tpp.distribution.base module#
- class gluonts.mx.model.tpp.distribution.base.TPPDistribution[source]#
Bases:
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.
- cdf(y: Union[NDArray, Symbol]) Union[NDArray, Symbol] [source]#
Return the value of the cumulative distribution function evaluated at x.
- log_intensity(x: Union[NDArray, Symbol]) Union[NDArray, Symbol] [source]#
Logarithm of the intensity (a.k.a. hazard) function.
The intensity is defined as
.
- log_prob(x: Union[NDArray, Symbol]) Union[NDArray, 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[NDArray, Symbol]) Union[NDArray, 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[NDArray, 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:
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[NDArray, Symbol]] = None) Union[TPPDistribution, 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: TPPDistribution, transforms: List[Bijection])[source]#
Bases:
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: TPPDistribution#
- cdf(y: Union[NDArray, Symbol]) Union[NDArray, Symbol] [source]#
Return the value of the cumulative distribution function evaluated at x.
- log_intensity(y: Union[NDArray, Symbol]) Union[NDArray, Symbol] [source]#
Logarithm of the intensity (a.k.a. hazard) function.
The intensity is defined as
.
- log_survival(y: Union[NDArray, Symbol]) Union[NDArray, Symbol] [source]#
Logarithm of the survival function.
- sample(num_samples=None, dtype=<class 'numpy.float32'>, lower_bound: ~typing.Optional[~typing.Union[~mxnet.ndarray.ndarray.NDArray, ~mxnet.symbol.symbol.Symbol]] = None) Union[NDArray, 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