gmtorch package#

Module contents#

Gaussian Mixture.

class gmtorch.GaussianMixture(n_components: int = 1, dim: int = 1, weights: Tensor | None = None, means: Tensor | None = None, covariances: Tensor | None = None, device: device | str = 'cpu')[source]#

Bases: object

Gaussian Mixture Class.

Parameters (6): - n_components (int) - dim (int) - weights (Tensor) shape (n_components,) - means (Tensor) shape (n_components, dim) - covariances (Tensor) shape (n_components, dim, dim) - device (torch.device or str)

covariance() Tensor[source]#

Compute the covariance matrix of the Gaussian Mixture.

Returns:

- Tensor

Return type:

covariance matrix of shape (dim, dim)

expectation() Tensor[source]#

Compute the expectation value of the Gaussian Mixture.

Returns:

- Tensor

Return type:

expectation value of shape (dim)

prob_hyperrec(event: Tensor, num_samples: int = 10000) Tensor[source]#

Compute the integral of the Gaussian Mixture over a hyperrectangle known as the “event”.

Parameters:

(Tensor) (- E)

Returns:

- Tensor

Return type:

integral value over the hyperrectangle

sample(n_samples: int, seed: int | None = None) Tensor[source]#

Generate samples from the Gaussian Mixture.

Parameters:
  • (int) (- num_samples)

  • (int (- seed)

  • optional) (random seed for reproducibility)

Returns:

- Tensor

Return type:

samples of shape (num_samples, dim)