torch_blue.vi.distributions.MeanFieldStudentT

class torch_blue.vi.distributions.MeanFieldStudentT(initial_scale: float = 1.0, degrees_of_freedom: float = 4.0, device: torch.device | None = None)

Bases: torch_blue.vi.distributions.base.Distribution

Distribution assuming uncorrelated Student’s t-distributions.

This distribution is implemented only as variational distribution.

Defines a variational Student’s t-distribution with initial mean zero. Learnable parameters are mean and log_scale; degrees_of_freedom can be provided but is fixed.

Parameters:
  • initial_scale (float, default: 1.0) – initial scale each independent distribution.

  • degrees_of_freedom (float, default: 4.0) – degrees of freedom each independent distribution.

sample(mean: torch.Tensor, log_scale: torch.Tensor) torch.Tensor

Draw sample from Student’s t-distribution.

Draw samples from a Student’s t-distribution with the given mean and log_scale. mean and log_scale must be broadcastable to the same shape.

Parameters:
  • mean (Tensor) – Sample mean.

  • log_scale (Tensor) – Sample distribution log scale.

Returns:

sample – Sample tensor of the same shape as mean drawn from Student’s t-distribution.

Return type:

Tensor

variational_log_prob(sample: torch.Tensor, mean: torch.Tensor, log_scale: torch.Tensor) torch.Tensor

Compute the log probability of a sample.

Computes the log probability of sample in a Student’s t-distribution with the given mean and log_scale.

Parameters:
  • sample (Tensor) – Sample tensor.

  • mean (Tensor) – Distribution mean.

  • log_scale (Tensor) – Distribution log scale.

Returns:

log_prob – Tensor with the same shape as sample containing the log probability of the sample given mean and log_scale.

Return type:

Tensor