projnormal.formulas.projected_normal.sampling
Sampling functions for the general projected normal distribution.
Functions
|
Compute the mean, covariance and second moment of the variable \(y = x/\sqrt{x^T x}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\), by sampling from the distribution. |
|
Sample the variable \(y = x/\sqrt{x^T x}\) where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\). |
- empirical_moments(mean_x, covariance_x, n_samples)
Compute the mean, covariance and second moment of the variable \(y = x/\sqrt{x^T x}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\), by sampling from the distribution. The variable \(y\) has a general projected normal distribution.
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).covariance_x (
torch.Tensor) – Covariance of x. Shape is(n_dim, n_dim).n_samples (
int) – Number of samples.
- Returns:
Dictionary with the keys
mean,covariance, andsecond_moment, containing the empirical moments of the projected normal distribution.- Return type:
dict
- sample(mean_x, covariance_x, n_samples)
Sample the variable \(y = x/\sqrt{x^T x}\) where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\).
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).covariance_x (
torch.Tensor) – Covariance of x. Shape is(n_dim, n_dim).n_samples (
int) – Number of samples.
- Returns:
Samples from the projected normal. Shape is
(n_samples, n_dim).- Return type:
torch.Tensor