# gluonts.distribution package¶

class gluonts.distribution.Distribution[source]

Bases: object

A class representing probability distributions.

property all_dim

Number of overall dimensions.

arg_names: Tuple = None
property args
property batch_dim

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

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.

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).

Returns

Tensor of shape batch_shape containing the CRPS score, according to the distribution, for each event in x.

Return type

Tensor

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_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).

Returns

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

Return type

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).

Returns

Tensor of shape batch_shape containing the value of the loss for each event in x.

Return type

Tensor

property 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).

Returns

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

Return type

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.

Returns

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.

Return type

quantiles

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

sample_rep(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
slice_axis(axis: int, begin: int, end: Optional[int]) → gluonts.distribution.distribution.Distribution[source]
property stddev

Tensor containing the standard deviation of the distribution.

property variance

Tensor containing the variance of the distribution.

class gluonts.distribution.DistributionOutput[source]

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

distr_cls: type = None
distribution(distr_args, loc: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

domain_map(F, *args: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_dim

Number of event dimensions, i.e., length of the event_shape tuple, of the distributions that this object constructs.

property event_shape

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

property value_in_support

A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By default 0.0. This value will be used when padding data series.

class gluonts.distribution.StudentTOutput[source]
args_dim: Dict[str, int] = {'mu': 1, 'nu': 1, 'sigma': 1}
distr_cls

alias of StudentT

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

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.StudentT(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], sigma: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], nu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Student’s t-distribution.

Parameters
• mu – Tensor containing the means, of shape (*batch_shape, *event_shape).

• sigma – Tensor containing the standard deviations, of shape (*batch_shape, *event_shape).

• nu – Nonnegative tensor containing the degrees of freedom of the distribution, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.GammaOutput[source]
args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1}
distr_cls

alias of Gamma

classmethod domain_map(F, alpha, beta)[source]

Maps raw tensors to valid arguments for constructing a Gamma distribution.

Parameters
• F

• alpha – Tensor of shape (*batch_shape, 1)

• beta – Tensor of shape (*batch_shape, 1)

Returns

Two squeezed tensors, of shape (*batch_shape): both have entries mapped to the positive orthant.

Return type

Tuple[Tensor, Tensor]

property event_shape

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

property value_in_support

A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By default 0.0. This value will be used when padding data series.

class gluonts.distribution.Gamma(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Gamma distribution.

Parameters
• alpha – Tensor containing the shape parameters, of shape (*batch_shape, *event_shape).

• beta – Tensor containing the rate parameters, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.BetaOutput[source]
args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1}
distr_cls

alias of Beta

classmethod domain_map(F, alpha, beta)[source]

Maps raw tensors to valid arguments for constructing a Beta distribution.

Parameters
• F

• alpha – Tensor of shape (*batch_shape, 1)

• beta – Tensor of shape (*batch_shape, 1)

Returns

Two squeezed tensors, of shape (*batch_shape): both have entries mapped to the positive orthant.

Return type

Tuple[Tensor, Tensor]

property event_shape

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

property value_in_support

A float that will have a valid numeric value when computing the log-loss of the corresponding distribution. By default 0.0. This value will be used when padding data series.

class gluonts.distribution.Beta(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Beta distribution.

Parameters
• alpha – Tensor containing the alpha shape parameters, of shape (*batch_shape, *event_shape).

• beta – Tensor containing the beta shape parameters, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property stddev

Tensor containing the standard deviation of the distribution.

property variance

Tensor containing the variance of the distribution.

class gluonts.distribution.GaussianOutput[source]
args_dim: Dict[str, int] = {'mu': 1, 'sigma': 1}
distr_cls

alias of Gaussian

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

Maps raw tensors to valid arguments for constructing a Gaussian distribution.

Parameters
• F

• mu – Tensor of shape (*batch_shape, 1)

• sigma – Tensor of shape (*batch_shape, 1)

Returns

Two squeezed tensors, of shape (*batch_shape): the first has the same entries as mu and the second has entries mapped to the positive orthant.

Return type

Tuple[Tensor, Tensor]

property event_shape

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

class gluonts.distribution.Gaussian(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], sigma: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Gaussian distribution.

Parameters
• mu – Tensor containing the means, of shape (*batch_shape, *event_shape).

• std – Tensor containing the standard deviations, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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.

cdf(x)[source]

Returns the value of the cumulative distribution function evaluated at x

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_reparameterizable = True
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

property mean

Tensor containing the mean of the distribution.

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.

Returns

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.

Return type

quantiles

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

sample_rep(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.LaplaceOutput[source]
args_dim: Dict[str, int] = {'b': 1, 'mu': 1}
distr_cls

alias of Laplace

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

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.Laplace(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], b: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Laplace distribution.

Parameters
• mu – Tensor containing the means, of shape (*batch_shape, *event_shape).

• b – Tensor containing the distribution scale, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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.

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

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_reparameterizable = True
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

property mean

Tensor containing the mean of the distribution.

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.

Returns

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.

Return type

quantiles

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

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.MultivariateGaussian(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], L: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Multivariate Gaussian distribution, specified by the mean vector and the Cholesky factor of its covariance matrix.

Parameters
• mu – mean vector, of shape (…, d)

• L – Lower triangular Cholesky factor of covariance matrix, of shape (…, d, d)

• F – A module that can either refer to the Symbol API or the NDArray API in MXNet

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_reparameterizable = True
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

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the multivariate Gaussian distributions. Internally, Cholesky factorization of the covariance matrix is used:

sample = L v + mu,

where L is the Cholesky factor, v is a standard normal sample.

Parameters
• num_samples – Number of samples to be drawn.

• dtype – Data-type of the samples.

Returns

Tensor with shape (num_samples, …, d).

Return type

Tensor

property variance

Tensor containing the variance of the distribution.

class gluonts.distribution.MultivariateGaussianOutput(dim: int)[source]
distr_cls = None
domain_map(F, mu_vector, L_vector)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.LowrankMultivariateGaussian(dim: int, rank: int, mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], D: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], W: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]

Multivariate Gaussian distribution, with covariance matrix parametrized as the sum of a diagonal matrix and a low-rank matrix

$\Sigma = D + W W^T$

The implementation is strongly inspired from Pytorch: https://github.com/pytorch/pytorch/blob/master/torch/distributions/lowrank_multivariate_normal.py.

Complexity to compute log_prob is $$O(dim * rank + rank^3)$$ per element.

Parameters
• dim – Dimension of the distribution’s support

• rank – Rank of W

• mu – Mean tensor, of shape (…, dim)

• D – Diagonal term in the covariance matrix, of shape (…, dim)

• W – Low-rank factor in the covariance matrix, of shape (…, dim, rank)

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_reparameterizable = True
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

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the multivariate Gaussian distribution:

$s = \mu + D u + W v,$

where $$u$$ and $$v$$ are standard normal samples.

Parameters
• num_samples – number of samples to be drawn.

• dtype – Data-type of the samples.

Returns

Return type

tensor with shape (num_samples, .., dim)

property variance

Tensor containing the variance of the distribution.

class gluonts.distribution.LowrankMultivariateGaussianOutput(dim: int, rank: int, sigma_init: float = 1.0, sigma_minimum: float = 0.001)[source]
distr_cls = None
distribution(distr_args, loc=None, scale=None, **kwargs) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

domain_map(F, mu_vector, D_vector, W_vector)[source]
Parameters
• F

• mu_vector – Tensor of shape (…, dim)

• D_vector – Tensor of shape (…, dim)

• W_vector – Tensor of shape (…, dim * rank )

Returns

A tuple containing tensors mu, D, and W, with shapes (…, dim), (…, dim), and (…, dim, rank), respectively.

Return type

Tuple

property event_shape

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

get_args_proj(prefix: Optional[str] = None) → gluonts.distribution.distribution_output.ArgProj[source]
class gluonts.distribution.MixtureDistributionOutput(distr_outputs: List[gluonts.distribution.distribution_output.DistributionOutput])[source]
distr_cls = None
distribution(distr_args, loc: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, **kwargs) → gluonts.distribution.mixture.MixtureDistribution[source]

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

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

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

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

property event_shape

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

get_args_proj(prefix: Optional[str] = None) → gluonts.distribution.mixture.MixtureArgs[source]
class gluonts.distribution.MixtureDistribution(mixture_probs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], components: List[gluonts.distribution.distribution.Distribution], F=None)[source]

A mixture distribution where each component is a Distribution.

Parameters
• mixture_probs – A tensor of mixing probabilities. The entries should all be positive and sum to 1 across the last dimension. Shape: (…, k), where k is the number of distributions to be mixed. All axis except the last one should either coincide with the ones from the component distributions, or be 1 (in which case, the mixing coefficient is shared across the axis).

• components – A list of k Distribution objects representing the mixture components. Distributions can be of different types. Each component’s support should be made of tensors of shape (…, d).

• F – A module that can either refer to the Symbol API or the NDArray API in MXNet

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.

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

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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.NegativeBinomialOutput[source]
args_dim: Dict[str, int] = {'alpha': 1, 'mu': 1}
distr_cls

alias of NegativeBinomial

distribution(distr_args, loc: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None) → gluonts.distribution.neg_binomial.NegativeBinomial[source]

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

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

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

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

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

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.NegativeBinomial(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Negative binomial distribution, i.e. the distribution of the number of successes in a sequence of independet Bernoulli trials.

Parameters
• mu – Tensor containing the means, of shape (*batch_shape, *event_shape).

• alpha – Tensor of the shape parameters, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.UniformOutput[source]
args_dim: Dict[str, int] = {'low': 1, 'width': 1}
distr_cls

alias of Uniform

classmethod domain_map(F, low, width)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.Uniform(low: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], high: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Uniform distribution.

Parameters
• low – Tensor containing the lower bound of the distribution domain.

• high – Tensor containing the higher bound of the distribution domain.

• F

arg_names = None
property args
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.

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

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_reparameterizable = True
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

property mean

Tensor containing the mean of the distribution.

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.

Returns

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.

Return type

quantiles

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

sample_rep(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.Binned(bin_log_probs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], bin_centers: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None, label_smoothing: Optional[float] = None)[source]

A binned distribution defined by a set of bins via bin centers and bin probabilities.

Parameters
• bin_log_probs – Tensor containing log probabilities of the bins, of shape (*batch_shape, num_bins).

• bin_centers – Tensor containing the bin centers, of shape (*batch_shape, num_bins).

• F

• label_smoothing – The label smoothing weight, real number in [0, 1). Default None. If not None, then the loss of the distribution will be “label smoothed” cross-entropy. For example, instead of computing cross-entropy loss between the estimated bin probabilities and a hard-label (one-hot encoding) [1, 0, 0], a soft label of [0.9, 0.05, 0.05] is taken as the ground truth (when label_smoothing=0.15). See (Muller et al., 2019) [MKH19], for further reference.

arg_names = None
property args
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 bin_probs
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

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_reparameterizable = False
log_prob(x)[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

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).

Returns

Tensor of shape batch_shape containing the value of the loss for each event in x.

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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.

Returns

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.

Return type

quantiles

sample(num_samples=None, dtype=<class 'numpy.float32'>)[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

smooth_ce_loss(x)[source]

Cross-entropy loss with a “smooth” label.

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.BinnedOutput(bin_centers: mxnet.ndarray.ndarray.NDArray, label_smoothing: Optional[float] = None)[source]
distr_cls

alias of Binned

distribution(args, loc=None, scale=None) → gluonts.distribution.binned.Binned[source]

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

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

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

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

property event_shape

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

get_args_proj(*args, **kwargs) → mxnet.gluon.block.HybridBlock[source]
class gluonts.distribution.PiecewiseLinear(gamma: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], slopes: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], knot_spacings: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Piecewise linear distribution.

This class represents the quantile function (i.e., the inverse CDF) associated with the a distribution, as a continuous, non-decreasing, piecewise linear function defined in the [0, 1] interval:

$q(x; \gamma, b, d) = \gamma + \sum_{l=0}^L b_l (x_l - d_l)_+$

where the input $$x \in [0,1]$$ and the parameters are

• $$\gamma$$: intercept at 0

• $$b$$: differences of the slopes in consecutive pieces

• $$d$$: knot positions

Parameters
• gamma – Tensor containing the intercepts at zero

• slopes – Tensor containing the slopes of each linear piece. All coefficients must be positive. Shape: (*gamma.shape, num_pieces)

• knot_spacings – Tensor containing the spacings between knots in the splines. All coefficients must be positive and sum to one on the last axis. Shape: (*gamma.shape, num_pieces)

• F

arg_names = None
property args
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.

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

Computes the quantile level $$\alpha$$ such that $$q(\alpha) = x$$.

Parameters

x – Tensor of shape gamma.shape

Returns

Tensor of shape gamma.shape

Return type

Tensor

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

Compute CRPS in analytical form.

Parameters

x – Observation to evaluate. Shape equals to gamma.shape.

Returns

Tensor containing the CRPS.

Return type

Tensor

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_reparameterizable = False
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).

Returns

Tensor of shape batch_shape containing the value of the loss for each event in x.

Return type

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.

Returns

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.

Return type

quantiles

quantile_internal(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], axis: Optional[int] = None) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Evaluates the quantile function at the quantile levels contained in x.

Parameters
• x – Tensor of shape *gamma.shape if axis=None, or containing an additional axis on the specified position, otherwise.

• axis – Index of the axis containing the different quantile levels which are to be computed.

Returns

Quantiles tensor, of the same shape as x.

Return type

Tensor

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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.distribution.PiecewiseLinearOutput(num_pieces: int)[source]
distr_cls

alias of PiecewiseLinear

distribution(distr_args, loc: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None) → gluonts.distribution.piecewise_linear.PiecewiseLinear[source]

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

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

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

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

classmethod domain_map(F, gamma, slopes, knot_spacings)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.Poisson(rate: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

Poisson distribution, i.e. the distribution of the number of successes in a specified region.

Parameters
• rate – Tensor containing the means, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.PoissonOutput[source]
args_dim: Dict[str, int] = {'rate': 1}
distr_cls

alias of Poisson

distribution(distr_args, loc: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None) → gluonts.distribution.poisson.Poisson[source]

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

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

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

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

classmethod domain_map(F, rate)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.TransformedPiecewiseLinear(base_distribution: gluonts.distribution.piecewise_linear.PiecewiseLinear, transforms: List[gluonts.distribution.bijection.Bijection])[source]
arg_names = None
crps(y: 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).

Returns

Tensor of shape batch_shape containing the CRPS score, according to the distribution, for each event in x.

Return type

Tensor

class gluonts.distribution.TransformedDistribution(base_distribution: gluonts.distribution.distribution.Distribution, transforms: List[gluonts.distribution.bijection.Bijection])[source]

A distribution obtained by applying a sequence of transformations on top of a base distribution.

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.

cdf(y: 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

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.

log_prob(y: 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

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.

Returns

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.

Return type

quantiles

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

sample_rep(num_samples: Optional[int] = None, dtype=<class 'float'>) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
class gluonts.distribution.TransformedDistributionOutput(base_distr_output: gluonts.distribution.distribution_output.DistributionOutput, transforms_output: List[gluonts.distribution.bijection_output.BijectionOutput])[source]

Class to connect a network to a distribution that is transformed by a sequence of learnable bijections.

distr_cls = None
distribution(distr_args, loc: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

domain_map(F, *args: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

get_args_proj(prefix: Optional[str] = None) → gluonts.distribution.distribution_output.ArgProj[source]
class gluonts.distribution.InverseBoxCoxTransformOutput(lb_obs: float = 0.0, fix_lambda_2: bool = True)[source]
args_dim: Dict[str, int] = {'box_cox.lambda_1': 1, 'box_cox.lambda_2': 1}
bij_cls

alias of InverseBoxCoxTransform

property event_shape
class gluonts.distribution.BoxCoxTransformOutput(lb_obs: float = 0.0, fix_lambda_2: bool = True)[source]
args_dim: Dict[str, int] = {'box_cox.lambda_1': 1, 'box_cox.lambda_2': 1}
bij_cls

alias of BoxCoxTransform

domain_map(F, *args: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], ...][source]
property event_shape
class gluonts.distribution.Dirichlet(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None, float_type: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Dirichlet distribution, specified by the concentration vector alpha of length d. https://en.wikipedia.org/wiki/Dirichlet_distribution

The Dirichlet distribution is defined on the open (d-1)-simplex, which means that a sample (or observation) x = (x_0,…, x_{d-1}) must satisfy:

sum_k x_k = 1 and for all k, x_k > 0.

Parameters
• alpha – concentration vector, of shape (…, d)

• F – A module that can either refer to the Symbol API or the NDArray API in MXNet

arg_names = None
property args
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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property variance

Tensor containing the variance of the distribution.

class gluonts.distribution.DirichletOutput(dim: int)[source]
distr_cls = None
distribution(distr_args, loc=None, scale=None) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

domain_map(F, alpha_vector)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.DirichletMultinomial(dim: int, n_trials: int, alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None, float_type: gluonts.core.component.DType = <class 'numpy.float32'>)[source]

Dirichlet-Multinomial distribution, specified by the concentration vector alpha of length dim, and a number of trials n_trials. https://en.wikipedia.org/wiki/Dirichlet-multinomial_distribution

The Dirichlet-Multinomial distribution is a discrete multivariate probability distribution, a sample (or observation) x = (x_0,…, x_{dim-1}) must satisfy:

sum_k x_k = n_trials and for all k, x_k is a non-negative integer.

Such a sample can be obtained by first drawing a vector p from a Dirichlet(alpha) distribution, then x is drawn from a Multinomial(p) with n trials

Parameters
• dim – Dimension of any sample

• n_trials – Number of trials

• alpha – concentration vector, of shape (…, dim)

• F – A module that can either refer to the Symbol API or the NDArray API in MXNet

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_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).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

sample(num_samples: Optional[int] = None, dtype=<class 'numpy.float32'>) → 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

property variance

Tensor containing the variance of the distribution.

class gluonts.distribution.DirichletMultinomialOutput(dim: int, n_trials: int)[source]
distr_cls = None
distribution(distr_args, loc=None, scale=None) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

domain_map(F, alpha_vector)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.Categorical(log_probs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

A categorical distribution over num_cats-many categories.

Parameters
• log_probs – Tensor containing log probabilities of the individual categories, of shape (*batch_shape, num_cats).

• F

arg_names = None
property args
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.

log_prob(x)[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

property mean

Tensor containing the mean of the distribution.

property probs
sample(num_samples=None, dtype=<class 'numpy.int32'>)[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

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.CategoricalOutput(num_cats: int)[source]
distr_cls

alias of Categorical

distribution(distr_args, loc=None, scale=None, **kwargs) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

domain_map(F, probs)[source]

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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

class gluonts.distribution.LogitNormal(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], sigma: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], F=None)[source]

The logit-normal distribution.

Parameters
• mu – Tensor containing the location, of shape (*batch_shape, *event_shape).

• sigma – Tensor indicating the scale, of shape (*batch_shape, *event_shape).

• F

arg_names = None
property args
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.

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

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.

Returns

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.

Return type

quantiles

sample(num_samples=None, dtype=<class 'numpy.float32'>)[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.distribution.LogitNormalOutput[source]
args_dim: Dict[str, int] = {'mu': 1, 'sigma': 1}
distr_cls

alias of LogitNormal

distribution(distr_args, loc=None, scale=None, **kwargs) → gluonts.distribution.distribution.Distribution[source]

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

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

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

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

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

Converts arguments to the right shape and domain. The domain depends on the type of distribution, while the correct shape is obtained by reshaping the trailing axis in such a way that the returned tensors define a distribution of the right event_shape.

property event_shape

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