Table Of Contents
Table Of Contents

gluonts.distribution package

class gluonts.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).
Returns:Tensor of shape batch_shape containing the CRPS score, according to the distribution, for each event in x.
Return type: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).
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
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]

Construct a new distribution by slicing all constructor arguments as specified by the provided bounds. Relies on mx.nd.slice_axis.

stddev

Tensor containing the standard deviation of the distribution.

variance

Tensor containing the variance of the distribution.

class gluonts.distribution.DistributionOutput[source]

Bases: gluonts.distribution.distribution_output.Output

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

distribution(distr_args, 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.
  • scale – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.
domain_map(F, *args)[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.

event_dim

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

event_shape

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

class gluonts.distribution.StudentTOutput[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

args_dim = {'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.

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]

Bases: gluonts.distribution.distribution.Distribution

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

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).
Returns:Tensor of shape batch_shape containing the log-density of the distribution for each event in x.
Return type:Tensor
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

stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.GaussianOutput[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

args_dim = {'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]

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]

Bases: gluonts.distribution.distribution.Distribution

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
args
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

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 = 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
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]
stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.LaplaceOutput[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

args_dim = {'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.

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]

Bases: gluonts.distribution.distribution.Distribution

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
args
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

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 = 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
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]
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]

Bases: gluonts.distribution.distribution.Distribution

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

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

variance

Tensor containing the variance of the distribution.

class gluonts.distribution.MultivariateGaussianOutput(dim: int)[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

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.

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]

Bases: gluonts.distribution.distribution.Distribution

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

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

variance

Tensor containing the variance of the distribution.

class gluonts.distribution.LowrankMultivariateGaussianOutput(dim: int, rank: int)[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

distribution(distr_args, 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.
  • 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

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]

Bases: gluonts.distribution.distribution_output.DistributionOutput

distribution(distr_args, 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.
  • scale – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.
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]

Bases: gluonts.distribution.distribution.Distribution

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

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).
Returns:Tensor of shape batch_shape containing the log-density of the distribution for each event in x.
Return type:Tensor
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

stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.NegativeBinomialOutput[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

args_dim = {'alpha': 1, 'mu': 1}
distr_cls

alias of NegativeBinomial

distribution(distr_args, scale=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.
  • 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.

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]

Bases: gluonts.distribution.distribution.Distribution

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

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).
Returns:Tensor of shape batch_shape containing the log-density of the distribution for each event in x.
Return type:Tensor
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

stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.UniformOutput[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

args_dim = {'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.

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]

Bases: gluonts.distribution.distribution.Distribution

Uniform distribution.

Parameters:
  • low – Tensor containing the lower bound of the distribution domain.
  • high – Tensor containing the higher bound of the distribution domain.
  • F
args
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

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 = 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
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]
stddev

Tensor containing the standard deviation of the distribution.

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

Bases: gluonts.distribution.distribution.Distribution

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

Parameters:
  • bin_probs – Tensor containing the bin probabilities, of shape (*batch_shape, num_bins).
  • bin_centers – Tensor containing the bin centers, of shape (*batch_shape, num_bins).
  • F
args
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

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

stddev

Tensor containing the standard deviation of the distribution.

class gluonts.distribution.BinnedOutput(bin_centers: mxnet.ndarray.ndarray.NDArray)[source]

Bases: gluonts.distribution.distribution_output.DistributionOutput

distr_cls

alias of Binned

distribution(args, 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.
  • scale – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.
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]

Bases: gluonts.distribution.distribution.Distribution

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
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
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
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]

Bases: gluonts.distribution.distribution_output.DistributionOutput

distr_cls

alias of PiecewiseLinear

distribution(distr_args, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = None, **kwargs) → 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.
  • 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.

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]

Bases: gluonts.distribution.transformed_distribution.TransformedDistribution, gluonts.distribution.piecewise_linear.PiecewiseLinear

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]

Bases: gluonts.distribution.distribution.Distribution

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

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

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.

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]

Bases: gluonts.distribution.distribution_output.DistributionOutput

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

distribution(distr_args, scale: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol, None] = 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.
  • scale – Optional tensor, of the same shape as the batch_shape+event_shape of the resulting distribution.
domain_map(F, *args)[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.

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]

Bases: gluonts.distribution.box_cox_tranform.BoxCoxTransformOutput

args_dim = {'box_cox.lambda_1': 1, 'box_cox.lambda_2': 1}
bij_cls

alias of InverseBoxCoxTransform

event_shape
class gluonts.distribution.BoxCoxTransformOutput(lb_obs: float = 0.0, fix_lambda_2: bool = True)[source]

Bases: gluonts.distribution.bijection_output.BijectionOutput

args_dim = {'box_cox.lambda_1': 1, 'box_cox.lambda_2': 1}
bij_cls

alias of BoxCoxTranform

domain_map(F, *args) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], ...][source]
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]

Bases: gluonts.distribution.distribution.Distribution

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

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).
Returns:Tensor of shape batch_shape containing the log-density of the distribution for each event in x.
Return type:Tensor
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

variance

Tensor containing the variance of the distribution.