projnormal.formulas.projected_normal_iso.sampling
Sampling functions for the isotropic 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)\) and \(\Sigma_x = \sigma^2 I\), by sampling from the distribution. |
|
Sample the variable \(y = x/\sqrt{x^T x}\) where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(\Sigma_x = \sigma^2 I\). |
- empirical_moments(mean_x, var_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)\) and \(\Sigma_x = \sigma^2 I\), by sampling from the distribution.
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).var_x (
torch.Tensor) – Variance of x. Shape is().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, var_x, n_samples)
Sample the variable \(y = x/\sqrt{x^T x}\) where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(\Sigma_x = \sigma^2 I\).
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).var_x (
torch.tensor) – variance of x. shape is().n_samples (
int) – Number of samples.
- Returns:
Samples from the projected normal. Shape is
(n_samples, n_dim).- Return type:
torch.Tensor