Distribution

class Distribution[source]

Bases: ABC

Base class for representing probability distributions.

abstract classmethod mean(*args, **kwargs) Tensor[source]

Computes the expected value of the distribution.

Returns:

mean of the distribution with given parameters.

Return type:

torch.Tensor

Raises:

NotImplementedError – must be implemented by the subclass.

abstract classmethod sample(*args, **kwargs) Tensor[source]

Samples random variates from the distribution.

Returns:

resulting random variates.

Return type:

torch.Tensor

Raises:

NotImplementedError – must be implemented by the subclass.

abstract classmethod validate(*args, **kwargs) dict[str, Tensor | bool | None][source]

Tests if the arguments are valid for the distribution.

Returns:

argument name and if it is valid, returned as a tensor of dtype torch.bool if a non-scalar tensor is given, None if not given.

Return type:

dict[str, torch.Tensor | bool | None]

Raises:

NotImplementedError – must be implemented by the subclass.

abstract classmethod variance(*args, **kwargs) Tensor[source]

Computes the variance of the distribution.

Returns:

variance of the distribution with given parameters.

Return type:

torch.Tensor

Raises:

NotImplementedError – must be implemented by the subclass.