gluonts.mx.distribution package#

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

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

property variance: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

class gluonts.mx.distribution.BetaOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1}#
distr_cls#

alias of gluonts.mx.distribution.beta.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: Tuple#

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

property value_in_support: float#

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.mx.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], label_smoothing: Optional[float] = None)[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

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.

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

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

property support_min_max: Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]#
class gluonts.mx.distribution.BinnedOutput(bin_centers: mxnet.ndarray.ndarray.NDArray, label_smoothing: Optional[float] = None)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls#

alias of gluonts.mx.distribution.binned.Binned

distribution(args, loc=None, scale=None) gluonts.mx.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: Tuple#

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.mx.distribution.BoxCoxTransformOutput(lb_obs: float = 0.0, fix_lambda_2: bool = True)[source]#

Bases: gluonts.mx.distribution.bijection_output.BijectionOutput

args_dim: Dict[str, int] = {'box_cox.lambda_1': 1, 'box_cox.lambda_2': 1}#
bij_cls#

alias of gluonts.mx.distribution.box_cox_transform.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: Tuple#
class gluonts.mx.distribution.Categorical(log_probs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

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.mx.distribution.CategoricalOutput(num_cats: int, temperature: float = 1.0)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls#

alias of gluonts.mx.distribution.categorical.Categorical

distribution(distr_args, loc=None, scale=None, **kwargs) gluonts.mx.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: Tuple#

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

class gluonts.mx.distribution.Deterministic(value: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

Deterministic/Degenerate distribution. :param value: Tensor containing the values, of shape (*batch_shape, *event_shape). :param F:

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

cdf(x)[source]#

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

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: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.DeterministicOutput(value: float)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'value': 1}#
distr_cls#

alias of gluonts.mx.distribution.deterministic.Deterministic

property event_shape: Tuple#

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

get_args_proj(prefix: Optional[str] = None) mxnet.gluon.block.HybridBlock[source]#
class gluonts.mx.distribution.Dirichlet(alpha: typing.Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], float_type: typing.Type = <class 'numpy.float32'>)[source]#

Bases: gluonts.mx.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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

class gluonts.mx.distribution.DirichletMultinomial(dim: int, n_trials: int, alpha: typing.Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], float_type: typing.Type = <class 'numpy.float32'>)[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

class gluonts.mx.distribution.DirichletMultinomialOutput(dim: int, n_trials: int)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls: type#
distribution(distr_args, loc=None, scale=None) gluonts.mx.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: Tuple#

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

class gluonts.mx.distribution.DirichletOutput(dim: int)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls: type#
distribution(distr_args, loc=None, scale=None) gluonts.mx.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: Tuple#

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

class gluonts.mx.distribution.Distribution[source]#

Bases: object

A class representing probability distributions.

property F#
property all_dim: int#

Number of overall dimensions.

arg_names: Tuple#
property args: List#
property batch_dim: int#

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

property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return 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: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

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: typing.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: typing.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.mx.distribution.distribution.Distribution[source]#
property stddev: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

property support_min_max: Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]#
property variance: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

class gluonts.mx.distribution.DistributionOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.Output

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

distr_cls: type#
distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.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: int#

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

property event_shape: Tuple#

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

property value_in_support: float#

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.mx.distribution.EmpiricalDistribution(samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], event_dim: int)[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

A class representing empirical distribution.

The target can be vector/tensor-valued, i.e., event_shape can be larger than or equal to 1. However, note that each dimension is assumed to be independent when computing variance and CRPS loss.

Also, for computing CDF and quantiles, it is assumede that samples are distinct along the samples dimension, which should almost always be the case if samples are drawn from continuous distributions.

Parameters
  • samples – Tensor containing samples, of shape (num_samples, *batch_shape, *event_shape).

  • 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 F#
arg_names: Tuple#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return the value of the cumulative distribution function evaluated at x.

crps_univariate(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 obs according to the empirical distribution.

The last dimension of obs specifies the “event dimension” of the target (= 1 for the univariate case). For multivariate target, CRSP scores are computed for each dimension separately and then their sum is returned.

Parameters

x – Tensor of ground truth with shape (*batch_shape, *event_shape)

Returns

CRPS score of shape (*batch_shape, 1).

Return type

Tensor

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

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

quantile_losses(obs: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], quantiles: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], levels: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Computes quantile losses for all the quantiles specified.

Parameters
  • obs – Ground truth observation. Shape: (batch_size, seq_len, *event_shape)

  • quantiles – Quantile values. Shape: (batch_size, seq_len, *event_shape, num_quantiles)

  • levels – Quantile levels. Shape: (batch_size, seq_len, *event_shape, num_quantiles)

Returns

Quantile losses of shape: (batch_size, seq_len, *event_shape, num_quantiles)

Return type

Tensor

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.EmpiricalDistributionOutput(num_samples: int, distr_output: gluonts.mx.distribution.distribution_output.DistributionOutput)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

This allows us to wrap EmpiricalDistribution by any parametric distribution and learn the parameters by minimizing CRPS loss on the samples of EmpiricalDistribution.

See the inference test test_empirical_distribution in test.distribution.test_mx_distribution_inference which checks if the CRPS loss is correctly implemented.

args_dim: Dict[str, int]#
distr_cls: type#
distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.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, **kwargs)[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: Tuple#

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

get_args_proj(prefix: Optional[str] = None) gluonts.mx.distribution.distribution_output.ArgProj[source]#
class gluonts.mx.distribution.FixedKnotsPiecewiseLinearOutput(quantile_levels: Union[List[float], numpy.ndarray])[source]#

Bases: gluonts.mx.distribution.piecewise_linear.PiecewiseLinearOutput

A simple extension of PiecewiseLinearOutput that “fixes” the knot positions in the quantile function representation. That is, instead of initializing with the number of pieces, the quantiles are provided directly at initialization.

Parameters

quantile_levels

Points along the domain of the quantile function (i.e., in the interval [0,1]) where the knots of the piecewise linear approximation will be fixed, provided in sorted order (ascending).

For more information on the piecewise linear quantile function, refer to gluonts.distribution.PiecewiseLinear.

distr_cls#

alias of gluonts.mx.distribution.piecewise_linear.PiecewiseLinear

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.

get_args_proj(prefix: Optional[str] = None) gluonts.mx.distribution.distribution_output.ArgProj[source]#
class gluonts.mx.distribution.Gamma(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.GammaOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1}#
distr_cls#

alias of gluonts.mx.distribution.gamma.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: Tuple#

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

property value_in_support: float#

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.mx.distribution.Gaussian(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], sigma: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

cdf(x)[source]#

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

classmethod fit(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Returns an instance of Gaussian after fitting parameters to the given data.

Parameters
  • F

  • samples – Tensor of shape (num_samples, batch_size, seq_len)

Return type

Distribution instance of type Gaussian.

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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

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: typing.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: typing.Optional[int] = None, dtype=<class 'numpy.float32'>) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#
property stddev: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.GaussianOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of gluonts.mx.distribution.gaussian.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: Tuple#

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

class gluonts.mx.distribution.GenPareto(xi: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

Generalised Pareto distribution.

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

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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

quantile(level: 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: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

property support_min_max: Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]#
property variance: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

class gluonts.mx.distribution.GenParetoOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'beta': 1, 'xi': 1}#
distr_cls#

alias of gluonts.mx.distribution.genpareto.GenPareto

classmethod domain_map(F, xi, beta)[source]#

Maps raw tensors to valid arguments for constructing a Generalized Pareto distribution.

Parameters
  • F

  • xi – 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: Tuple#

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

property value_in_support: float#

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.mx.distribution.ISQF(spline_knots: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], spline_heights: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta_l: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta_r: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], qk_y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], qk_x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], num_qk: int, num_pieces: int, tol: float = 0.0001)[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

Distribution class for the Incremental (Spline) Quantile Function in the paper Learning Quantile Functions without Quantile Crossing for Distribution-free Time Series Forecasting by Park, Robinson, Aubet, Kan, Gasthaus, Wang.

Parameters
  • spline_knots – Tensor parametrizing the x-positions (y-positions) of the spline knots Shape: (*batch_shape, (num_qk-1), num_pieces)

  • spline_heights – Tensor parametrizing the x-positions (y-positions) of the spline knots Shape: (*batch_shape, (num_qk-1), num_pieces)

  • qk_x – Tensor containing the increasing x-positions (y-positions) of the quantile knots, Shape: (*batch_shape, num_qk)

  • qk_y – Tensor containing the increasing x-positions (y-positions) of the quantile knots, Shape: (*batch_shape, num_qk)

  • beta_l – Tensor containing the non-negative learnable parameter of the left (right) tail, Shape: (*batch_shape,)

  • beta_r – Tensor containing the non-negative learnable parameter of the left (right) tail, Shape: (*batch_shape,)

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

cdf(z: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Computes the quantile level alpha_tilde such that q(alpha_tilde) = z :param z: Tensor of shape = (*batch_shape,)

Returns

Tensor of shape = (*batch_shape,)

Return type

alpha_tilde

cdf_spline(z: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

For observations z and splines defined in [qk_x[k], qk_x[k+1]] Computes the quantile level alpha_tilde such that alpha_tilde.

= q^{-1}(z) if z is in-between qk_x[k] and qk_x[k+1] = qk_x[k] if z<qk_x[k] = qk_x[k+1] if z>qk_x[k+1] :param z: Observation, shape = (*batch_shape,)

Returns

Corresponding quantile level, shape = (*batch_shape, num_qk-1)

Return type

alpha_tilde

cdf_tail(z: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], left_tail: bool = True) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Computes the quantile level alpha_tilde such that alpha_tilde.

= q^{-1}(z) if z is in the tail region = qk_x_l or qk_x_r if z is in the non-tail region

Parameters
  • z – Observation, shape = (*batch_shape,)

  • left_tail – If True, compute alpha_tilde for the left tail Otherwise, compute alpha_tilde for the right tail

Returns

Corresponding quantile level, shape = (*batch_shape,)

Return type

alpha_tilde

crps(z: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Compute CRPS in analytical form :param z: Observation to evaluate. Shape = (*batch_shape,)

Returns

Tensor containing the CRPS, of the same shape as z

Return type

Tensor

crps_spline(z: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Compute CRPS in analytical form for the spline :param z: Observation to evaluate. shape = (*batch_shape,)

Returns

Tensor containing the CRPS, of the same shape as z

Return type

Tensor

crps_tail(z: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], left_tail: bool = True) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Compute CRPS in analytical form for left/right tails.

Parameters
  • z – Observation to evaluate. shape = (*batch_shape,)

  • left_tail – If True, compute CRPS for the left tail Otherwise, compute CRPS for the right tail

Returns

Tensor containing the CRPS, of the same shape as z

Return type

Tensor

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False#
loss(z: 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

static parametrize_qk(F, quantile_knots: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]][source]#

Function to parametrize the x or y positions of the num_qk quantile knots.

Parameters

quantile_knots – x or y positions of the quantile knots shape: (*batch_shape, num_qk)

Returns

  • qk – x or y positions of the quantile knots (qk), with index=1, …, num_qk-1, shape: (*batch_shape, num_qk-1)

  • qk_plus – x or y positions of the quantile knots (qk), with index=2, …, num_qk, shape: (*batch_shape, num_qk-1)

  • qk_l – x or y positions of the left-most quantile knot (qk), shape: (*batch_shape)

  • qk_r – x or y positions of the right-most quantile knot (qk), shape: (*batch_shape)

static parametrize_spline(F, spline_knots: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], qk: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], qk_plus: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], num_pieces: int, tol: float = 0.0001) Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]][source]#

Function to parametrize the x or y positions of the spline knots :param spline_knots: variable that parameterizes the spline knot positions :param qk: x or y positions of the quantile knots (qk),

with index=1, …, num_qk-1, shape: (*batch_shape, num_qk-1)

Parameters
  • qk_plus – x or y positions of the quantile knots (qk), with index=2, …, num_qk, shape: (*batch_shape, num_qk-1)

  • num_pieces – number of spline knot pieces

  • tol – tolerance hyperparameter for numerical stability

Returns

  • sk – x or y positions of the spline knots (sk), shape: (*batch_shape, num_qk-1, num_pieces)

  • delta_sk – difference of x or y positions of the spline knots (sk), shape: (*batch_shape, num_qk-1, num_pieces)

static parametrize_tail(F, beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], qk_x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], qk_y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]][source]#

Function to parametrize the tail parameters.

Note that the exponential tails are given by q(alpha) = a_l log(alpha) + b_l if left tail = a_r log(1-alpha) + b_r if right tail

where a_l=1/beta_l, b_l=-a_l*log(qk_x_l)+q(qk_x_l) a_r=1/beta_r, b_r=a_r*log(1-qk_x_r)+q(qk_x_r)

Parameters
  • beta – parameterizes the left or right tail, shape: (*batch_shape,)

  • qk_x – left- or right-most x-positions of the quantile knots, shape: (*batch_shape,)

  • qk_y – left- or right-most y-positions of the quantile knots, shape: (*batch_shape,)

Returns

  • tail_a – a_l or a_r as described above

  • tail_b – b_l or b_r as described above

quantile(input_alpha: 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(alpha: 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 input_alpha :param alpha: Tensor of shape = (*batch_shape,) if axis=None, or containing an

additional axis on the specified position, otherwise

Parameters

axis – Index of the axis containing the different quantile levels which are to be computed. Read the description below for detailed information

Returns

Quantiles tensor, of the same shape as alpha

Return type

Tensor

quantile_spline(alpha: 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 spline functions at the quantile levels contained in alpha.

Parameters
  • alpha – Input quantile levels

  • axis – Axis along which to expand For details of input_alpha shape and axis, refer to the description in quantile_internal

Returns

Quantiles tensor with shape = (*batch_shape, num_qk-1) if axis = None = (1, *batch_shape, num_qk-1) if axis = 0 = (*batch_shape, num_qk-1, num_pieces) if axis = -2

Return type

Tensor

quantile_tail(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], axis: Optional[int] = None, left_tail: bool = True) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Evaluates the tail functions at the quantile levels contained in alpha :param alpha: Input quantile levels :param axis: Axis along which to expand

For details of input_alpha shape and axis, refer to the description in quantile_internal

Parameters

left_tail – If True, compute the quantile for the left tail Otherwise, compute the quantile for the right tail

Returns

Quantiles tensor, of the same shape as alpha

Return type

Tensor

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

Function used to draw random samples :param num_samples: number of samples :param dtype: data type

Returns

Tensor of shape (*batch_shape,) if num_samples = None else (num_samples, *batch_shape)

Return type

Tensor

class gluonts.mx.distribution.ISQFOutput(num_pieces: int, qk_x: List[float], tol: float = 0.0001)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

DistributionOutput class for the Incremental (Spline) Quantile Function.

Parameters
  • num_pieces – number of spline pieces for each spline ISQF reduces to IQF when num_pieces = 1

  • alpha – Tensor containing the x-positions of quantile knots

  • tol – tolerance for numerical safeguarding

distr_cls#

alias of gluonts.mx.distribution.isqf.ISQF

distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.distribution.isqf.ISQF[source]#

function outputing the distribution class distr_args: distribution arguments loc: shift to the data mean scale: scale to the data

classmethod domain_map(F, *args: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], tol: float = 0.0001) Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]][source]#

Domain map function The inputs of this function are specified by self.args_dim knots, heights:

parameterizing the x-/ y-positions of the spline knots, shape = (*batch_shape, (num_qk-1)*num_pieces) q: parameterizing the y-positions of the quantile knots, shape = (*batch_shape, num_qk) beta_l, beta_r: parameterizing the left/right tail, shape = (*batch_shape, 1)

property event_shape: Tuple#

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

reshape_spline_args(distr_args, qk_x)[source]#

auxiliary function reshaping knots and heights to (*batch_shape, num_qk-1, num_pieces) alpha to (*batch_shape, num_qk)

class gluonts.mx.distribution.InverseBoxCoxTransformOutput(lb_obs: float = 0.0, fix_lambda_2: bool = True)[source]#

Bases: gluonts.mx.distribution.box_cox_transform.BoxCoxTransformOutput

args_dim: Dict[str, int] = {'box_cox.lambda_1': 1, 'box_cox.lambda_2': 1}#
bij_cls#

alias of gluonts.mx.distribution.box_cox_transform.InverseBoxCoxTransform

property event_shape: Tuple#
class gluonts.mx.distribution.Laplace(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], b: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.LaplaceFixedVarianceOutput[source]#

Bases: gluonts.mx.distribution.laplace.LaplaceOutput

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.

class gluonts.mx.distribution.LaplaceOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of gluonts.mx.distribution.laplace.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: Tuple#

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

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

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

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.mx.distribution.LogitNormalOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of gluonts.mx.distribution.logit_normal.LogitNormal

distribution(distr_args, loc=None, scale=None, **kwargs) gluonts.mx.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: Tuple#

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

class gluonts.mx.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: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None)[source]#

Bases: gluonts.mx.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\]

When W = None the covariance matrix is just diagonal.

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) Optional; if not provided, the covariance matrix is just diagonal.

property F#
arg_names: Tuple#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

classmethod fit(F, samples: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], rank: int = 0) gluonts.mx.distribution.distribution.Distribution[source]#

Returns an instance of LowrankMultivariateGaussian after fitting parameters to the given data. Only the special case of rank = 0 is supported at the moment.

Parameters
  • F

  • samples – Tensor of shape (num_samples, batch_size, seq_len, target_dim)

  • rank – Rank of W

Return type

Distribution instance of type LowrankMultivariateGaussian.

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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample_rep(num_samples: typing.Optional[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.

Return type

tensor with shape (num_samples, …, dim)

property variance: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

class gluonts.mx.distribution.LowrankMultivariateGaussianOutput(dim: int, rank: int, sigma_init: float = 1.0, sigma_minimum: float = 0.001)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int]#
distr_cls: type#
distribution(distr_args, loc=None, scale=None, **kwargs) gluonts.mx.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=None)[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: Tuple#

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

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

Bases: gluonts.mx.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 axes 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

property F#
arg_names: Tuple#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

property support_min_max: Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]#
class gluonts.mx.distribution.MixtureDistributionOutput(distr_outputs: List[gluonts.mx.distribution.distribution_output.DistributionOutput])[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int]#
distr_cls: type#
distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, **kwargs) gluonts.mx.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: Tuple#

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

get_args_proj(prefix: Optional[str] = None) gluonts.mx.distribution.mixture.MixtureArgs[source]#
property value_in_support: float#

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

property F#
arg_names: Tuple#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample_rep(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the variance of the distribution.

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

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int]#
distr_cls: type#
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: Tuple#

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

class gluonts.mx.distribution.NanMixture(nan_prob: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], distribution: gluonts.mx.distribution.distribution.Distribution, F=None)[source]#

Bases: gluonts.mx.distribution.mixture.MixtureDistribution

A mixture distribution of a NaN-valued Deterministic distribution and Distribution.

Parameters
  • nan_prob – A tensor of the probabilities of missing values. The entries should all be positive and smaller than 1. All axis should either coincide with the ones from the component distributions, or be 1 (in which case, the NaN probability is shared across the axis).

  • distribution – A Distribution object representing the Distribution of non-NaN values. 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: Tuple#
property distribution#
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 nan_prob#
class gluonts.mx.distribution.NanMixtureOutput(distr_output: gluonts.mx.distribution.distribution_output.DistributionOutput)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls#

alias of gluonts.mx.distribution.nan_mixture.NanMixture

distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, **kwargs) gluonts.mx.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: Tuple#

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

get_args_proj(prefix: Optional[str] = None) gluonts.mx.distribution.nan_mixture.NanMixtureArgs[source]#
class gluonts.mx.distribution.NegativeBinomial(mu: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

Negative binomial distribution, i.e. the distribution of the number of successes in a sequence of independent 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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.NegativeBinomialOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of gluonts.mx.distribution.neg_binomial.NegativeBinomial

distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.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: Tuple#

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

class gluonts.mx.distribution.OneInflatedBeta(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], one_probability: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.inflated_beta.ZeroAndOneInflatedBeta

One Inflated Beta distribution as in Raydonal Ospina, Silvia L.P. Ferrari: Inflated Beta Distributions.

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

  • one_probability – Tensor containing the probability of ones, of shape (*batch_shape, *event_shape).

  • F

arg_names: Tuple#
is_reparameterizable = False#
class gluonts.mx.distribution.OneInflatedBetaOutput[source]#

Bases: gluonts.mx.distribution.inflated_beta.ZeroInflatedBetaOutput

args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1, 'one_probability': 1}#
distr_cls#

alias of gluonts.mx.distribution.inflated_beta.OneInflatedBeta

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

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

Parameters
  • F

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

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

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

Returns

Three squeezed tensors, of shape (*batch_shape): First two have entries mapped to the positive orthant, last is mapped to (0,1)

Return type

Tuple[Tensor, Tensor, Tensor]

class gluonts.mx.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])[source]#

Bases: gluonts.mx.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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: typing.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.mx.distribution.PiecewiseLinearOutput(num_pieces: int)[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls#

alias of gluonts.mx.distribution.piecewise_linear.PiecewiseLinear

distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.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: Tuple#

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

class gluonts.mx.distribution.Poisson(rate: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.PoissonOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'rate': 1}#
distr_cls#

alias of gluonts.mx.distribution.poisson.Poisson

distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.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: Tuple#

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

class gluonts.mx.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.mx.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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the mean of the distribution.

sample(num_samples: typing.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.StudentTOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of gluonts.mx.distribution.student_t.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: Tuple#

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

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

Bases: gluonts.mx.distribution.distribution.Distribution

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

property F#
arg_names: Tuple#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

cdf(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#

Return 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: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

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: typing.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: typing.Optional[int] = None, dtype=<class 'float'>) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#
property support_min_max: Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]]#
class gluonts.mx.distribution.TransformedDistributionOutput(base_distr_output: gluonts.mx.distribution.distribution_output.DistributionOutput, transforms_output: List[gluonts.mx.distribution.bijection_output.BijectionOutput])[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

args_dim: Dict[str, int]#
distr_cls: type#
distribution(distr_args, loc: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None, scale: Optional[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]] = None) gluonts.mx.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: Tuple#

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

get_args_proj(prefix: Optional[str] = None) gluonts.mx.distribution.distribution_output.ArgProj[source]#
class gluonts.mx.distribution.TransformedPiecewiseLinear(base_distribution: gluonts.mx.distribution.piecewise_linear.PiecewiseLinear, transforms: List[gluonts.mx.distribution.bijection.Bijection])[source]#

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

arg_names: Tuple#
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.mx.distribution.Uniform(low: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], high: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.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

property F#
arg_names: Tuple#
property args: List#
property batch_shape: Tuple#

Layout of the set of events contemplated by the distribution.

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

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

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

Return the value of the cumulative distribution function evaluated at x.

property event_dim: int#

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

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

property event_shape: Tuple#

Shape of each individual event contemplated by the distribution.

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

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

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

is_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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

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: typing.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: typing.Optional[int] = None, dtype=<class 'numpy.float32'>) Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]#
property stddev: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]#

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.UniformOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'low': 1, 'width': 1}#
distr_cls#

alias of gluonts.mx.distribution.uniform.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: Tuple#

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

class gluonts.mx.distribution.ZeroAndOneInflatedBeta(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], zero_probability: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], one_probability: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.mixture.MixtureDistribution

Zero And One Inflated Beta distribution as in Raydonal Ospina, Silvia L.P. Ferrari: Inflated Beta Distributions

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

  • zero_probability – Tensor containing the probability of zeros, of shape (*batch_shape, *event_shape).

  • one_probability – Tensor containing the probability of ones, of shape (*batch_shape, *event_shape).

  • F

arg_names: Tuple#
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

class gluonts.mx.distribution.ZeroAndOneInflatedBetaOutput[source]#

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1, 'one_probability': 1, 'zero_probability': 1}#
distr_cls#

alias of gluonts.mx.distribution.inflated_beta.ZeroAndOneInflatedBeta

classmethod domain_map(F, alpha, beta, zero_probability, one_probability)[source]#

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

Parameters
  • F

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

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

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

Returns

Four squeezed tensors, of shape (*batch_shape): First two have entries mapped to the positive orthant, zero_probability is mapped to (0, 1), one_probability is mapped to (0, 1-zero_probability)

Return type

Tuple[Tensor, Tensor, Tensor, Tensor]

property event_shape: Tuple#

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

property value_in_support: float#

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.mx.distribution.ZeroInflatedBeta(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], beta: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], zero_probability: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[source]#

Bases: gluonts.mx.distribution.inflated_beta.ZeroAndOneInflatedBeta

Zero Inflated Beta distribution as in Raydonal Ospina, Silvia L.P. Ferrari: Inflated Beta Distributions.

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

  • zero_probability – Tensor containing the probability of zeros, of shape (*batch_shape, *event_shape).

  • F

arg_names: Tuple#
is_reparameterizable = False#
class gluonts.mx.distribution.ZeroInflatedBetaOutput[source]#

Bases: gluonts.mx.distribution.inflated_beta.ZeroAndOneInflatedBetaOutput

args_dim: Dict[str, int] = {'alpha': 1, 'beta': 1, 'zero_probability': 1}#
distr_cls#

alias of gluonts.mx.distribution.inflated_beta.ZeroInflatedBeta

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

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

Parameters
  • F

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

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

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

Returns

Three squeezed tensors, of shape (*batch_shape): First two have entries mapped to the positive orthant, last is mapped to (0,1)

Return type

Tuple[Tensor, Tensor, Tensor]

gluonts.mx.distribution.ZeroInflatedNegativeBinomialOutput() gluonts.mx.distribution.mixture.MixtureDistributionOutput[source]#
gluonts.mx.distribution.ZeroInflatedPoissonOutput() gluonts.mx.distribution.mixture.MixtureDistributionOutput[source]#