projnormal.param_sampling
Functions for randomly sampling distribution parameters.
Functions
|
Generate a vector to use as the mean of a multivariate normal. |
|
Generate a set of orthogonal vectors. |
|
Make a symmetric positive definite matrix. |
- make_mean(n_dim, shape='gaussian', sparsity=0.1)
Generate a vector to use as the mean of a multivariate normal.
- Parameters:
n_dim (
int) – Dimension of the mean vector.shape (
str) – Type of mean vector. Options are:'gaussian'(each element sampled from N(0,1)),'exponential'(each element sampled from Exp(1)),'sin'(sin-wave vector with random phase frequency and amplitude),'sparse'(sparse vector with 0s and 1s)sparsity (
float) – For'sparse'shape, the fraction of non-zero elements
- Returns:
Mean vector. Shape is
(n_dim,).- Return type:
torch.Tensor
- make_ortho_vectors(n_dim, n_vec)
Generate a set of orthogonal vectors.
- Parameters:
n_dim (
int) – Dimension of the vectors.n_vec (
int) – Number of orthogonal vectors to generate. Must be less than n_dim.
- Returns:
Orthogonal vectors of size n_dim x n_vec. Shape is
(n_vec, n_dim).- Return type:
torch.Tensor
- make_spdm(n_dim, eigvals='uniform', eigvecs='random')
Make a symmetric positive definite matrix.
- Parameters:
n_dim (
int) – Dimension of matrixeigvals (
strortorch.Tensor) – Eigenvalues of the matrix. Options are: 1) Tensor of eigvals to use, of lengthn_dim. 2) ‘uniform’: Eigvals are uniformly sampled between 0.1 and 1. 3)'exponential': Eigvals sampled from Exp(1).eigvecs (str) – Eigenvectors of the matrix. Options are: 1)``’random’
: Random orthogonal matrix. 2) ``'identity': Identity matrix.
- Returns:
Symmetric positive definite matrix with specified eigvals. Shape is
(n_dim, n_dim).- Return type:
torch.Tensor