gluonts.mx.distribution.dirichlet_multinomial module¶
-
class
gluonts.mx.distribution.dirichlet_multinomial.
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.dirichlet_multinomial.
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.
-