Chi2

class paddle.distribution. Chi2 ( df: float | Tensor ) [source]

Creates a Chi-squared distribution parameterized by shape parameter. This is exactly equivalent to Gamma(concentration=0.5*df, rate=0.5), Gamma.

Parameters

df (float or Tensor) – The degree of freedom of the distribution, which should be non-negative. If the input data type is Tensor, it indicates the batch creation of distributions with multiple different parameters, and the batch_shape (refer to the Distribution base class) is the parameter.

Example

>>> import paddle
>>> m = paddle.distribution.Chi2(paddle.to_tensor([1.0]))
>>> sample = m.sample()
>>> sample.shape
[1]
property batch_shape : Sequence[int]

Returns batch shape of distribution

Returns

batch shape

Return type

Sequence[int]

entropy ( ) Tensor

entropy

Entropy of gamma distribution

Returns

Entropy.

Return type

Tensor

property event_shape : Sequence[int]

Returns event shape of distribution

Returns

event shape

Return type

Sequence[int]

kl_divergence ( other: Gamma ) Tensor [source]

kl_divergence

The KL-divergence between two gamma distributions.

Parameters

other (Gamma) – instance of Gamma.

Returns

kl-divergence between two gamma distributions.

Return type

Tensor

log_prob ( value: float | Tensor ) Tensor

log_prob

Log probability density function evaluated at value

Parameters

value (float|Tensor) – Value to be evaluated

Returns

Log probability.

Return type

Tensor

property mean : Tensor

Mean of gamma distribution.

Returns

mean value.

Return type

Tensor

prob ( value: float | Tensor ) Tensor

prob

Probability density function evaluated at value

Parameters

value (float|Tensor) – Value to be evaluated.

Returns

Probability.

Return type

Tensor

probs ( value: Tensor ) Tensor

probs

Probability density/mass function.

Note

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

rsample ( shape: Sequence[int] = [] ) Tensor

rsample

Generate reparameterized samples of the specified shape.

Parameters

shape (Sequence[int], optional) – Shape of the generated samples.

Returns

A tensor with prepended dimensions shape.The data type is float32.

Return type

Tensor

sample ( shape: Sequence[int] = [] ) Tensor

sample

Generate samples of the specified shape.

Parameters

shape (Sequence[int], optional) – Shape of the generated samples.

Returns

Tensor, A tensor with prepended dimensions shape.The data type is float32.

property variance : Tensor

Variance of gamma distribution.

Returns

variance value.

Return type

Tensor