# gluonts.distribution.distribution module¶

class gluonts.distribution.distribution.Distribution[source]

Bases: object

A class representing probability distributions.

all_dim

Number of overall dimensions.

args
batch_dim

Number of batch dimensions, i.e., length of the batch_shape tuple.

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.

cdf(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Returns the value of the cumulative distribution function evaluated at x

crps(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the continuous rank probability score (CRPS) of x according to the distribution.

Parameters: x – Tensor of shape (*batch_shape, *event_shape). Tensor of shape batch_shape containing the CRPS score, according to the distribution, for each event in x. Tensor
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.

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_reparameterizable = False
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). Tensor of shape batch_shape containing the log-density of the distribution for each event in x. Tensor
loss(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the loss at x according to the distribution.

By default, this method returns the negative of log_prob. For some distributions, however, the log-density is not easily computable and therefore other loss functions are computed.

Parameters: x – Tensor of shape (*batch_shape, *event_shape). Tensor of shape batch_shape containing the value of the loss for each event in x. Tensor
mean

Tensor containing the mean of the distribution.

prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the density of the distribution at x.

Parameters: x – Tensor of shape (*batch_shape, *event_shape). Tensor of shape batch_shape containing the density of the distribution for each event in x. Tensor
quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters: level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1. Quantile values corresponding to the levels passed. The return shape is (num_levels, …DISTRIBUTION_SHAPE…), where DISTRIBUTION_SHAPE is the shape of the underlying distribution. quantiles
sample(num_samples: Optional[int] = 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.

Returns: A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise. Tensor
sample_rep(num_samples: Optional[int] = None) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
stddev

Tensor containing the standard deviation of the distribution.

variance

Tensor containing the variance of the distribution.

gluonts.distribution.distribution.getF(var: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]
gluonts.distribution.distribution.nans_like(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
gluonts.distribution.distribution.softplus(F, x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]