MFStudentT

class viabel.MFStudentT(dim, df, seed=1)[source]

A mean-field Student’s t approximation family.

Attributes:
df

Degrees of freedom.

dim

Dimension of the space the distribution is defined on

supports_entropy

Whether the approximation family supports closed-form entropy computation.

supports_kl

Whether the approximation family supports closed-form KL divergence computation.

var_param_dim

Dimension of the variational parameter

Methods

entropy(var_param)

Compute entropy of variational distribution.

init_param()

A variational parameter to use for initialization.

kl(var_param0, var_param1)

Compute the Kullback-Leibler (KL) divergence.

log_density(var_param, x)

The log density of the variational distribution.

mean_and_cov(var_param)

The mean and covariance of the variational distribution.

pth_moment(var_param, p)

The absolute pth moment of the variational distribution.

sample(var_param, n_samples[, seed])

Generate samples from the variational distribution

supports_pth_moment(p)

Whether analytically computing the pth moment is supported

__init__(dim, df, seed=1)[source]
Parameters:
dimint

The dimension of the space the distributions in the approximation family are defined on.

var_param_dimint

The dimension of the variational parameter.

supports_entropybool

Whether the approximation family supports closed-form entropy computation.

supports_klbool

Whether the approximation family supports closed-form KL divergence computation.

entropy(var_param)[source]

Compute entropy of variational distribution.

Parameters:
var_paramnumpy.ndarray, shape (var_param_dim,)

The variational parameter.

Raises:
NotImplementedError

If entropy computation is not supported.

init_param()[source]

A variational parameter to use for initialization.

Returns:
var_paramnumpy.ndarray, shape (var_param_dim,)
log_density(var_param, x)[source]

The log density of the variational distribution.

Parameters:
var_paramnumpy.ndarray, shape (var_param_dim,)

The variational parameter.

xnumpy.ndarray, shape (dim,)

Value at which to evaluate the density.

mean_and_cov(var_param)[source]

The mean and covariance of the variational distribution.

Parameters:
var_paramnumpy.ndarray, shape (var_param_dim,)

The variational parameter.

sample(var_param, n_samples, seed=None)[source]

Generate samples from the variational distribution

Parameters:
var_paramnumpy.ndarray, shape (var_param_dim,)

The variational parameter.

n_samplesint

The number of samples to generate.

Returns:
samplesnumpy.ndarray, shape (n_samples, var_param_dim)
supports_pth_moment(p)[source]

Whether analytically computing the pth moment is supported