projnormal.formulas.projected_normal_c

Formulas for the distribution of \(y=x/\sqrt{\|x\|^2 + c}\).

empirical_moments(mean_x, covariance_x, const, n_samples)

Compute the mean, covariance and second moment of the variable \(y = x/\sqrt{x^T x + c}\) where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(c\) is a positive constant added to the denominator, by sampling from the 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).

  • const (torch.Tensor) – Constant added to the denominator. Shape is ().

  • n_samples (int) – Number of samples to draw.

Returns:

Dictionary with the keys mean, covariance, and second_moment, containing the empirical moments of the projected normal distribution.

Return type:

dict

log_pdf(mean_x, covariance_x, const, y)

Compute the log-pdf at points y for the distribution of the variable \(y = x/\sqrt{x^T x + c}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(c\) is a positive constant.

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).

  • y (torch.Tensor) – Points where to evaluate the PDF. Shape is (n_points, n_dim).

  • const (torch.Tensor) – Constant added to the denominator. Must be positive. Shape is ().

Returns:

Log-PDF evaluated at each y. Shape is (n_points,).

Return type:

torch.Tensor

mean(mean_x, covariance_x, const=0)

Compute the mean of \(y = x/\sqrt{x^T x + c}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(c\) is a positive constant. Uses a Taylor approximation.

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).

  • const (torch.Tensor) – Constant added to the denominator. Shape is ().

Returns:

Expected value for the projected normal on ellipse. Shape is (n_dim,).

Return type:

torch.Tensor

pdf(mean_x, covariance_x, const, y)

Compute the pdf at points y for the distribution of the variable \(y = x/\sqrt{x^T x + c}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(c\) is a positive constant.

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).

  • y (torch.Tensor) – Points where to evaluate the PDF. Shape is (n_points, n_dim).

  • const (torch.Tensor) – Constant added to the denominator. Must be positive. Shape is ().

Returns:

PDF evaluated at each y. Shape is (n_points,).

Return type:

torch.Tensor

sample(mean_x, covariance_x, const, n_samples)

Sample the variable \(y = x/\sqrt{x^T x + c}\) where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(c\) is a constant added to the denominator.

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).

  • const (torch.Tensor) – Constant added to the denominator. Shape is ().

  • n_samples (int) – Number of samples to draw.

Returns:

Samples from the distribution. Shape is (n_samples, n_dim).

Return type:

torch.Tensor

second_moment(mean_x, covariance_x, const)

Compute the second moment matrix of \(y = x/\sqrt{x^T x + c}\), where \(x \sim \mathcal{N}(\mu_x, \Sigma_x)\) and \(c\) is a positive constant. Uses a Taylor approximation.

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).

  • const (torch.Tensor) – Constant added to the denominator. Shape is ().

Returns:

Second moment matrix of \(y\). Shape is (n_dim, n_dim).

Return type:

torch.Tensor

Modules

moments

Approximation to the moments of the general projected normal distribution with additive const term in denominator.

probability

Probability density function (PDF) for the general projected normal distribution with an additive constant const in the denominator .

sampling

Sampling functions for the general projected normal distribution with an additive constant const in the denominator.