Dirichlet

class paddle.distribution. Dirichlet ( concentration ) [source]

Dirichlet distribution with parameter “concentration”.

The Dirichlet distribution is defined over the (k-1)-simplex using a positive, length-k vector concentration(k > 1). The Dirichlet is identically the Beta distribution when k = 2.

For independent and identically distributed continuous random variable \(\boldsymbol X \in R_k\) , and support \(\boldsymbol X \in (0,1), ||\boldsymbol X|| = 1\) , The probability density function (pdf) is

\[f(\boldsymbol X; \boldsymbol \alpha) = \frac{1}{B(\boldsymbol \alpha)} \prod_{i=1}^{k}x_i^{\alpha_i-1}\]

where \(\boldsymbol \alpha = {\alpha_1,...,\alpha_k}, k \ge 2\) is parameter, the normalizing constant is the multivariate beta function.

\[B(\boldsymbol \alpha) = \frac{\prod_{i=1}^{k} \Gamma(\alpha_i)}{\Gamma(\alpha_0)}\]

\(\alpha_0=\sum_{i=1}^{k} \alpha_i\) is the sum of parameters, \(\Gamma(\alpha)\) is gamma function.

Parameters

concentration (Tensor) – “Concentration” parameter of dirichlet distribution, also called \(\alpha\). When it’s over one dimension, the last axis denotes the parameter of distribution, event_shape=concentration.shape[-1:] , axes other than last are consider batch dimensions with batch_shape=concentration.shape[:-1] .

Examples

>>> import paddle
>>> dirichlet = paddle.distribution.Dirichlet(paddle.to_tensor([1., 2., 3.]))
>>> print(dirichlet.entropy())
Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True,
-1.24434423)

>>> print(dirichlet.prob(paddle.to_tensor([.3, .5, .6])))
Tensor(shape=[], dtype=float32, place=Place(cpu), stop_gradient=True,
10.80000019)
property mean

Mean of Dirichlet distribution.

Returns

Mean value of distribution.

property variance

Variance of Dirichlet distribution.

Returns

Variance value of distribution.

sample ( shape=() )

sample

Sample from dirichlet distribution.

Parameters

shape (Sequence[int], optional) – Sample shape. Defaults to empty tuple.

prob ( value )

prob

Probability density function(PDF) evaluated at value.

Parameters

value (Tensor) – Value to be evaluated.

Returns

PDF evaluated at value.

log_prob ( value )

log_prob

Log of probability density function.

Parameters

value (Tensor) – Value to be evaluated.

entropy ( )

entropy

Entropy of Dirichlet distribution.

Returns

Entropy of distribution.

property batch_shape

Returns batch shape of distribution

Returns

batch shape

Return type

Sequence[int]

property event_shape

Returns event shape of distribution

Returns

event shape

Return type

Sequence[int]

kl_divergence ( other ) [source]

kl_divergence

The KL-divergence between self distributions and other.

probs ( value )

probs

Probability density/mass function.

Note

This method will be deprecated in the future, please use prob instead.

rsample ( shape=() )

rsample

reparameterized sample