projnormal.formulas.projected_normal_iso
Formulas for the projected normal distribution with isotropic covariance matrix of \(x\).
- 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
- log_pdf(mean_x, var_x, y)
Compute the log-pdf at points y for the distribution of the variable \(y = x/\sqrt{x^T x}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(\Sigma_x = \sigma^2 I\) (isotropic covariance matrix).
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).var_x (
torch.tensor) – variance of x. shape is().y (
torch.Tensor) – Points where to evaluate the PDF. Shape is(n_points, n_dim).
- Returns:
Log-PDF evaluated at each y. Shape is
(n_points,).- Return type:
torch.Tensor
- mean(mean_x, var_x)
Compute the mean of \(y = x/\sqrt{x^T x}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(\Sigma_x = \sigma^2 I\). This is done using the exact analytic formulas.
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).var_x (
torch.tensor) – variance of x. shape is().
- Returns:
Expected value for the projected normal. Shape is
(n_dim,).- Return type:
torch.Tensor
- pdf(mean_x, var_x, y)
Compute the pdf at points y for the distribution of the variable \(y = x/\sqrt{x^T x}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(\Sigma_x = \sigma^2 I\) (isotropic covariance matrix).
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).var_x (
torch.tensor) – variance of x. shape is().y (
torch.Tensor) – Points where to evaluate the PDF. Shape is(n_points, n_dim).
- Returns:
PDF evaluated at each y. Shape is
(n_points,).- Return type:
torch.Tensor
- 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
- second_moment(mean_x, var_x)
Compute the second moment matrix of \(y = x/\sqrt{x^T x}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(\Sigma_x = \sigma^2 I\). This is done using the exact analytic formulas.
- Parameters:
mean_x (
torch.Tensor) – Mean of x. Shape is(n_dim,).var_x (
torch.tensor) – variance of x. shape is().
- Returns:
Second moment matrix of \(y\). Shape is
(n_dim, n_dim).- Return type:
torch.Tensor
Modules
Exact moments of the projected normal distribution with isotropic covariance. |
|
Probability density function (PDF) for the projected normal distribution with isotropic covariance of the unprojected Gaussian. |
|
Sampling functions for the isotropic projected normal distribution. |