# Beta¶

class paddle.distribution. Beta ( alpha, beta ) [source]

Beta distribution parameterized by alpha and beta.

In probability theory and statistics, the beta distribution is a family of continuous probability distributions defined on the interval [0, 1] parameterized by two positive shape parameters, denoted by alpha and beta, that appear as exponents of the random variable and control the shape of the distribution. The generalization to multiple variables is called a Dirichlet distribution.

The probability density function (pdf) is

$f(x; \alpha, \beta) = \frac{1}{B(\alpha, \beta)}x^{\alpha-1}(1-x)^{\beta-1}$

where the normalization, B, is the beta function,

$B(\alpha, \beta) = \int_{0}^{1} t^{\alpha - 1} (1-t)^{\beta - 1}\mathrm{d}t$
Parameters
• alpha (float|Tensor) – Alpha parameter. It supports broadcast semantics. The value of alpha must be positive. When the parameter is a tensor, it represents multiple independent distribution with a batch_shape(refer to Distribution ).

• beta (float|Tensor) – Beta parameter. It supports broadcast semantics. The value of beta must be positive(>0). When the parameter is tensor, it represent multiple independent distribution with a batch_shape(refer to Distribution ).

Examples

import paddle

# scale input
print(beta.mean)
#        [0.50000000])
print(beta.variance)
#        [0.12500000])
print(beta.entropy())
#        [0.12500000])

print(beta.mean)
#        [0.25000000, 0.40000001])
print(beta.variance)
#        [0.10416666, 0.12000000])
print(beta.entropy())
#        [-1.91923141, -0.38095069])

property mean

Mean of beta distribution.

property variance

Variance of beat distribution

prob ( value )

Probability density funciotn evaluated at value

Parameters

value (Tensor) – Value to be evaluated.

Returns

Probability.

Return type

Tensor

log_prob ( value )

Log probability density funciton evaluated at value

Parameters

value (Tensor) – Value to be evaluated

Returns

Log probability.

Return type

Tensor

sample ( shape=() )

Sample from beta distribution with sample shape.

Parameters

shape (Sequence[int], optional) – Sample shape.

Returns

Sampled data with shape sample_shape + batch_shape + event_shape.

entropy ( )

Entropy of dirichlet distribution

Returns

Entropy.

Return type

Tensor

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]

The KL-divergence between self distributions and other.

probs ( value )

Probability density/mass function.

Note

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

rsample ( shape=() )

reparameterized sample