gluonts.torch.distributions.binned_uniforms module#

class gluonts.torch.distributions.binned_uniforms.BinnedUniforms(bins_lower_bound: float, bins_upper_bound: float, logits: torch.Tensor, numb_bins: int = 100, validate_args: Optional[bool] = None)[source]#

Bases: torch.distributions.distribution.Distribution

Binned uniforms distribution.

Parameters
  • bins_lower_bound (float) – The lower bound of the bin edges

  • bins_upper_bound (float) – The upper bound of the bin edges

  • numb_bins (int) – The number of equidistance bins to allocate between bins_lower_bound and bins_upper_bound. Default value is 100.

  • logits (tensor) – the logits defining the probability of each bins. These are softmaxed. The tensor is of shape (*batch_shape,)

  • validate_args (bool) –

arg_constraints = {'logits': Real()}#
property bins_prob#

Returns the probability of the observed point to be in each of the bins bins_prob.shape: (*batch_shape, event_shape). event_shape is numb_bins

cdf(x)[source]#

Cumulative density tensor for a tensor of data points x.

‘x’ is expected to be of shape (*batch_shape)

entropy()[source]#

We do not have an implementation of the entropy yet.

enumerate_support(expand=True)[source]#

This is a real valued distribution.

expand(batch_shape, _instance=None)[source]#

Returns a new distribution instance (or populates an existing instance provided by a derived class) with batch dimensions expanded to batch_shape. This method calls expand on the distribution’s parameters. As such, this does not allocate new memory for the expanded distribution instance. Additionally, this does not repeat any args checking or parameter broadcasting in __init__.py, when an instance is first created.

Parameters
  • batch_shape (torch.Size) – the desired expanded size.

  • _instance – new instance provided by subclasses that need to override .expand.

Returns

New distribution instance with batch dimensions expanded to batch_size.

get_one_hot_bin_indicator(x, in_float=False)[source]#

‘x’ is to have shape (*batch_shape) which can be for example () or (32, ) or (32, 168, )

has_rsample = False#
icdf(quantiles)[source]#

Inverse cdf of a tensor of quantile quantiles ‘quantiles’ is of shape (*batch_shape) with values between (0.0, 1.0)

This is the function to be called from the outside.

log_binned_p(x)[source]#

Log probability for a tensor of datapoints x.

‘x’ is to have shape (*batch_shape)

property log_bins_prob#
log_prob(x)[source]#

Log probability for a tensor of datapoints x.

‘x’ is to have shape (*batch_shape)

property mean#

Returns the mean of the distribution.

mean.shape : (*batch_shape,)

property median#

Returns the median of the distribution.

median.shape : (*batch_shape,)

property mode#

Returns the mode of the distribution.

mode.shape : (*batch_shape,)

pdf(x)[source]#

Probability for a tensor of data points x.

‘x’ is to have shape (*batch_shape)

rsample(sample_shape=torch.Size([]))[source]#

We do not have an implementation for the reparameterization trick yet.

sample(sample_shape=torch.Size([]))[source]#

Returns samples from the distribution.

Returns

samples of shape (*sample_shape, *batch_shape)

support = Real()#
variance()[source]#

Returns the variance of the distribution.

class gluonts.torch.distributions.binned_uniforms.BinnedUniformsOutput(bins_lower_bound: float, bins_upper_bound: float, num_bins: int)[source]#

Bases: gluonts.torch.distributions.distribution_output.DistributionOutput

distr_cls#

alias of gluonts.torch.distributions.binned_uniforms.BinnedUniforms

distribution(distr_args, loc: Optional[torch.Tensor] = None, scale: Optional[torch.Tensor] = None) gluonts.torch.distributions.binned_uniforms.BinnedUniforms[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(logits: torch.Tensor) torch.Tensor[source]#

Converts arguments to the right shape and domain.

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

property event_shape: Tuple#

Shape of each individual event compatible with the output object.