Exponential

class paddle.distribution. Exponential ( rate ) [source]

Exponential distribution parameterized by rate.

The probability density function (pdf) is

\[f(x; \theta) = \theta e^{- \theta x }, (x \ge 0) $$\]

In the above equation:

  • \(rate = \theta\): is the rate parameter.

Parameters

rate (float|Tensor) – Rate parameter. The value of rate must be positive.

Example

>>> import paddle

>>> expon = paddle.distribution.Exponential(paddle.to_tensor([0.5]))
>>> print(expon.mean)
Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [2.])

>>> print(expon.variance)
Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [4.])

>>> print(expon.entropy())
Tensor(shape=[1], dtype=float32, place=Place(gpu:0), stop_gradient=True,
       [1.69314718])
property mean

Mean of exponential distribution.

Returns

mean value.

Return type

Tensor

property variance

Variance of exponential distribution.

Returns

variance value.

Return type

Tensor

sample ( shape=() )

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.

rsample ( shape=() )

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

prob ( value )

prob

Probability density function evaluated at value.

\[{ f(x; \theta) = \theta e^{- \theta x}, (x \ge 0 ) }\]
Parameters

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

Returns

Probability.

Return type

Tensor

log_prob ( value )

log_prob

Log probability density function evaluated at value.

Parameters

value (float|Tensor) – Value to be evaluated

Returns

Log probability.

Return type

Tensor

entropy ( )

entropy

Entropy of exponential distribution.

Returns

Entropy.

Return type

Tensor

cdf ( value )

cdf

Cumulative distribution function(CDF) evaluated at value.

\[{ cdf(x; \theta) = 1 - e^{- \theta x }, (x \ge 0) }\]
Parameters

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

Returns

CDF evaluated at value.

Return type

Tensor

icdf ( value )

icdf

Inverse cumulative distribution function(CDF) evaluated at value.

\[{ icdf(x; \theta) = -\frac{ 1 }{ \theta } ln(1 + x), (x \ge 0) }\]
Parameters

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

Returns

CDF evaluated at value.

Return type

Tensor

kl_divergence ( other ) [source]

kl_divergence

The KL-divergence between two exponential distributions.

Parameters

other (Exponential) – instance of Exponential.

Returns

kl-divergence between two exponential distributions.

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]

probs ( value )

probs

Probability density/mass function.

Note

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