gluonts.model.tpp.distribution.loglogistic module

class gluonts.model.tpp.distribution.loglogistic.Loglogistic(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], sigma: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]

Bases: gluonts.model.tpp.distribution.base.TPPDistribution

Log-logistic distribution.

A very heavy-tailed distribution over positive real numbers. https://en.wikipedia.org/wiki/Log-logistic_distribution

Drawing \(x \sim \operatorname{Loglogistic}(\mu, \sigma)\) is equivalent to:

\[\begin{split}y &\sim \operatorname{Logistic}(\mu, \sigma)\\ x &= \exp(y)\end{split}\]
arg_names = None
property batch_shape

Layout of the set of events contemplated by the distribution.

Invoking sample() from a distribution yields a tensor of shape batch_shape + event_shape, and computing log_prob (or loss more in general) on such sample will yield a tensor of shape batch_shape.

This property is available in general only in mx.ndarray mode, when the shape of the distribution arguments can be accessed.

property event_dim

Number of event dimensions, i.e., length of the event_shape tuple.

This is 0 for distributions over scalars, 1 over vectors, 2 over matrices, and so on.

property event_shape

Shape of each individual event contemplated by the distribution.

For example, distributions over scalars have event_shape = (), over vectors have event_shape = (d, ) where d is the length of the vectors, over matrices have event_shape = (d1, d2), and so on.

Invoking sample() from a distribution yields a tensor of shape batch_shape + event_shape.

This property is available in general only in mx.ndarray mode, when the shape of the distribution arguments can be accessed.

is_reparametrizable = True
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)\).

We define \(z = (\log(x) - \mu) / \sigma\) and obtain the intensity as \(\lambda(x) = sigmoid(z) / (\sigma * \log(x))\), or equivalently \(\log \lambda(x) = z - \log(1 + \exp(z)) - \log(\sigma) - \log(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))\).

We define \(z = (\log(x) - \mu) / \sigma\) and obtain the survival function as \(S(x) = sigmoid(-z)\), or equivalently \(\log S(x) = -\log(1 + \exp(z))\).

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

We generate samples as \(u \sim Uniform(0, 1), x = S^{-1}(u)\), where \(S^{-1}\) is the inverse of the survival function \(S(x) = 1 - CDF(x)\).

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

Sampled inter-event times. Shape: (num_samples, *batch_size)

Return type

x

class gluonts.model.tpp.distribution.loglogistic.LoglogisticOutput[source]

Bases: gluonts.model.tpp.distribution.base.TPPDistributionOutput

args_dim: Dict[str, int] = {'mu': 1, 'sigma': 1}
distr_cls

alias of Loglogistic

classmethod domain_map(F, mu, sigma)[source]

Maps raw tensors to valid arguments for constructing a log-logistic distribution.

Parameters
  • F – MXNet backend.

  • mu – Mean of the underlying logistic distribution. Shape (*batch_shape, 1)

  • sigma – Scale of the underlying logistic distribution. Shape (*batch_shape, 1)

Returns

Two squeezed tensors of shape (*batch_shape). The sigma parameter is strictly positive.

Return type

Tuple[Tensor, Tensor]

property event_shape

Shape of each individual event contemplated by the distributions that this object constructs.