gluonts.mx.model.tpp.distribution.weibull module#
- class gluonts.mx.model.tpp.distribution.weibull.Weibull(rate: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], shape: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#
Bases:
gluonts.mx.model.tpp.distribution.base.TPPDistribution
Weibull distribution.
We use the parametrization of the Weibull distribution using the rate parameter \(b > 0\) and the shape parameter \(k > 0\). The PDF is \(p(x) = b * k * x^{(k - 1)} * \exp(-b * x^k)\). An alternative parametrization is often used (e.g. on Wikipedia), where we use the scale parameter \(\lambda > 0\) and the shape parameter \(k > 0\), and \(\lambda = b^{-1/k}\).
- arg_names: Tuple#
- property batch_shape: Tuple#
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: int#
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: Tuple#
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)\).
The intensity of the Weibull distribution is \(\lambda(x) = b * k * x^{k - 1}\).
- 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))\).
The survival function of the Weibull distribution is \(S(x) = \exp(-b * x^k)\).
- property mean: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#
Tensor containing the mean of the distribution.
- 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.
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.mx.model.tpp.distribution.weibull.WeibullOutput[source]#
Bases:
gluonts.mx.model.tpp.distribution.base.TPPDistributionOutput
- args_dim: Dict[str, int] = {'rate': 1, 'shape': 1}#
- distr_cls#
- classmethod domain_map(F, rate, shape)[source]#
Maps raw tensors to valid arguments for constructing a Weibull distribution.
- Parameters
F – MXNet backend.
rate – Rate (inverse scale) parameter of the Weibull distribution. Shape (*batch_shape, 1)
shape – Shape parameter of the Weibull distribution. Shape (*batch_shape, 1)
- Returns
Two squeezed tensors of shape (*batch_shape). Both tensors are strictly positive.
- Return type
Tuple[Tensor, Tensor]
- property event_shape: Tuple#
Shape of each individual event contemplated by the distributions that this object constructs.