gluonts.mx.distribution package

class gluonts.mx.distribution.Distribution[source]

Bases: object

A class representing probability distributions.

property F
property all_dim

Number of overall dimensions.

arg_names: Tuple = None
property args
property batch_dim

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

property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

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

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

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

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

Compute the loss at x according to the distribution.

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

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Compute the density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

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

Tensor containing the standard deviation of the distribution.

property support_min_max
property variance

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

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

property event_shape

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

property value_in_support

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

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

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

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

property event_shape

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

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.GammaOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of Gamma

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

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

Parameters
  • F

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

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

Returns

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

Return type

Tuple[Tensor, Tensor]

property event_shape

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

property value_in_support

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

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.BetaOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of Beta

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

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

Parameters
  • F

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

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

Returns

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

Return type

Tuple[Tensor, Tensor]

property event_shape

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

property value_in_support

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

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

property variance

Tensor containing the variance of the distribution.

class gluonts.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 = None
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 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

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

property value_in_support

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

class gluonts.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 = None
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 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]

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 = None
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 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.GenParetoOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

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

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

property value_in_support

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

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

property support_min_max
property variance

Tensor containing the variance 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 Gaussian

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

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

Parameters
  • F

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

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

Returns

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

Return type

Tuple[Tensor, Tensor]

property event_shape

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

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

cdf(x)[source]

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = True
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

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

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.LaplaceOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of Laplace

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

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

property event_shape

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

class gluonts.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.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = True
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

Tensor containing the standard deviation of the distribution.

class gluonts.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 = None
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = True
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

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

sample = L v + mu,

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

Parameters
  • num_samples – Number of samples to be drawn.

  • dtype – Data-type of the samples.

Returns

Tensor with shape (num_samples, …, d).

Return type

Tensor

property variance

Tensor containing the variance of the distribution.

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

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls = None
domain_map(F, mu_vector, L_vector)[source]

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

property event_shape

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

class gluonts.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: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol])[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\]

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)

property F
arg_names = None
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = True
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the multivariate Gaussian distribution:

\[s = \mu + D u + W v,\]

where \(u\) and \(v\) are standard normal samples.

Parameters
  • num_samples – number of samples to be drawn.

  • dtype – Data-type of the samples.

Returns

Return type

tensor with shape (num_samples, .., dim)

property variance

Tensor containing the variance of the distribution.

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

distr_cls = None
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)[source]
Parameters
  • F

  • mu_vector – Tensor of shape (…, dim)

  • D_vector – Tensor of shape (…, dim)

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

Returns

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

Return type

Tuple

property event_shape

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

get_args_proj(prefix: Optional[str] = None) → gluonts.mx.distribution.distribution_output.ArgProj[source]
class gluonts.mx.distribution.MixtureDistributionOutput(distr_outputs: List[gluonts.mx.distribution.distribution_output.DistributionOutput])[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

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

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

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

property support_min_max
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 = None
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 NanMixture

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

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.NegativeBinomialOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of NegativeBinomial

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

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

class gluonts.mx.distribution.ZeroInflatedNegativeBinomialOutput[source]

Bases: gluonts.mx.distribution.mixture.MixtureDistributionOutput

distr_cls = None
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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.UniformOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of Uniform

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

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

property event_shape

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

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = True
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

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

Tensor containing the standard deviation of the distribution.

class gluonts.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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x)[source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

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

Compute the loss at x according to the distribution.

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

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

sample(num_samples=None, dtype=<class 'numpy.float32'>)[source]

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

smooth_ce_loss(x)[source]

Cross-entropy loss with a “smooth” label.

property stddev

Tensor containing the standard deviation of the distribution.

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

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

Layout of the set of events contemplated by the distribution.

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

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

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

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

Parameters

x – Tensor of shape gamma.shape

Returns

Tensor of shape gamma.shape

Return type

Tensor

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

Compute CRPS in analytical form.

Parameters

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

Returns

Tensor containing the CRPS.

Return type

Tensor

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
loss(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the loss at x according to the distribution.

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

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

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

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

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

Returns

Quantiles tensor, of the same shape as x.

Return type

Tensor

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

class gluonts.mx.distribution.PiecewiseLinearOutput(num_pieces: int)[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls

alias of PiecewiseLinear

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

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

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.PoissonOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

alias of Poisson

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

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

class gluonts.mx.distribution.ZeroInflatedPoissonOutput[source]

Bases: gluonts.mx.distribution.mixture.MixtureDistributionOutput

distr_cls = None
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 = None
crps(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

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

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

class gluonts.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 = None
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

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

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

log_prob(y: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

sample_rep(num_samples: Optional[int] = None, dtype=<class 'float'>) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]
property support_min_max
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.

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

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

property event_shape
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 BoxCoxTransform

domain_map(F, *args: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Tuple[Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], ...][source]
property event_shape
class gluonts.mx.distribution.Dirichlet(alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], float_type: gluonts.core.component.DType = <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 = None
property args
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property variance

Tensor containing the variance of the distribution.

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

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

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

class gluonts.mx.distribution.DirichletMultinomial(dim: int, n_trials: int, alpha: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol], float_type: gluonts.core.component.DType = <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 = None
property batch_shape

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = False
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property variance

Tensor containing the variance of the distribution.

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

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

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

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

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

log_prob(x)[source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

property probs
sample(num_samples=None, dtype=<class 'numpy.int32'>)[source]

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

Tensor containing the standard deviation of the distribution.

class gluonts.mx.distribution.CategoricalOutput(num_cats: int, temperature: float = 1.0)[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

distr_cls

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

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

Layout of the set of events contemplated by the distribution.

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

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

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

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

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

sample(num_samples=None, dtype=<class 'numpy.float32'>)[source]

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

class gluonts.mx.distribution.LogitNormalOutput[source]

Bases: gluonts.mx.distribution.distribution_output.DistributionOutput

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

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

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

Layout of the set of events contemplated by the distribution.

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

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

cdf(x)[source]

Returns the value of the cumulative distribution function evaluated at x

property event_dim

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

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

property event_shape

Shape of each individual event contemplated by the distribution.

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

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

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

is_reparameterizable = True
log_prob(x: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Compute the log-density of the distribution at x.

Parameters

x – Tensor of shape (*batch_shape, *event_shape).

Returns

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

Return type

Tensor

property mean

Tensor containing the mean of the distribution.

quantile(level: Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol]) → Union[mxnet.ndarray.ndarray.NDArray, mxnet.symbol.symbol.Symbol][source]

Calculates quantiles for the given levels.

Parameters

level – Level values to use for computing the quantiles. level should be a 1d tensor of level values between 0 and 1.

Returns

Quantile values corresponding to the levels passed. The return shape is

(num_levels, …DISTRIBUTION_SHAPE…),

where DISTRIBUTION_SHAPE is the shape of the underlying distribution.

Return type

quantiles

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

Draw samples from the distribution.

If num_samples is given the first dimension of the output will be num_samples.

Parameters
  • num_samples – Number of samples to to be drawn.

  • dtype – Data-type of the samples.

Returns

A tensor containing samples. This has shape (*batch_shape, *eval_shape) if num_samples = None and (num_samples, *batch_shape, *eval_shape) otherwise.

Return type

Tensor

property stddev

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 Deterministic

property event_shape

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]

Submodules