Sampling
|
Uniform sample on the unit sphere \(\mathbb{S}^{d-1}\). |
|
Uniform sample in an angle interval in dimension 2. |
|
Von Mises sample on the sphere \(\mathbb{S}^{d-1}\) using the Ulrich-Wood algorithm [W1994]. |
|
Sample rotations at random in balls centered around q, with radii given by the scales array. |
|
Von Mises random variables on the space of quaternions with center q and concentration parameter kappa. |
- sisyphe.sampling.uniform_sphere_rand(N, d, device, dtype=torch.float32)
Uniform sample on the unit sphere \(\mathbb{S}^{d-1}\).
- Parameters
N (int) – Number of samples.
d (int) – Dimension
device (torch.device) – Device on which the samples are created
dtype (torch.dtype, optional) – Default is torch.float32
- Returns
Sample.
- Return type
(N,D) Tensor
- sisyphe.sampling.uniform_angle_rand(mu, eta)
Uniform sample in an angle interval in dimension 2.
Add a uniform angle in \([-\pi\eta,\pi\eta]\) to the angle of mu.
- Parameters
mu ((N,2) Tensor) – Center of the distribution for each of the N samples.
eta ((N,2) Tensor or float) – Deviation for each of the N samples.
- Returns
Sample.
- Return type
(N,2) Tensor
- sisyphe.sampling.sample_W(kappa, N, d)
Sample the first coordinate of a von Mises distribution with center at \((1,0,...0)^T\) and concentration kappa.
- Parameters
kappa ((N,) Tensor) – Concentration parameter. Also accept (1,) Tensor if all the samples have the same concentration parameter.
N (int) – Number of samples. Must be equal to the size of kappa when the size of kappa is >1.
d – Dimension.
- Returns
Random sample in \(\mathbb{R}\).
- Return type
(N,) Tensor
- sisyphe.sampling.vonmises_rand(mu, kappa)
Von Mises sample on the sphere \(\mathbb{S}^{d-1}\) using the Ulrich-Wood algorithm [W1994].
- W1994(1,2)
A. Wood, Simulation of the von Mises Fisher distribution, Comm. Statist. Simulation Comput., Vol. 23, No. 1 (1994).
- Parameters
mu ((N,d) Tensor) – Centers of the N samples.
kappa – ((N,) Tensor or (1,) Tensor): Concentration parameter.
- Returns
Sample with center mu and concentration parameter kappa.
- Return type
(N,d) Tensor
- sisyphe.sampling.sample_angles(N, scales)
Sample angles by rejection sampling.
- sisyphe.sampling.uniformball_unitquat_rand(q, scales)
Sample rotations at random in balls centered around q, with radii given by the scales array.
- sisyphe.sampling.uniform_unitquat_rand(N, device, dtype=torch.float32)
Uniform sample in the space of unit quaternions.
- Parameters
N (int) – Number of samples.
device (torch.device) – Device on which the samples are created.
dtype (torch.dtype, optional) – Default is torch.float32.
- Returns
Samples.
- Return type
(N,4) Tensor
- sisyphe.sampling.sample_q0(kappa, N)
Sample N random variables distributed according to the von Mises distribution on the space of quaternions with center \((1,0,0,0)\) and concentration parameter kappa.
Use the BACG method described in [KGM2018].
- KGM2018
J. Kent, A. Ganeiber & K. Mardia, A New Unified Approach for the Simulation of a Wide Class of Directional Distributions, J. Comput. Graph. Statist., Vol. 27, No. 2 (2018).
- Parameters
kappa ((N,) Tensor or (1,) Tensor) – Concentration parameter.
N (int) – Number of samples. Must be equal to the size of kappa when the size of kappa is >1.
- Returns
Sample.
- Return type
(N,) Tensor
- sisyphe.sampling.vonmises_quat_rand(q, kappa)
Von Mises random variables on the space of quaternions with center q and concentration parameter kappa.
Multiply q with a sample from the von Mises distribution on the space of quaternions with center \((1,0,0,0)\) and concentration parameter kappa. See
sample_q0()
.- Parameters
q ((N,4) Tensor) – Center of the distribution.
kappa ((N,) Tensor or (1,) Tensor) – Concentration parameter.
- Returns
Sample.
- Return type
(N,4) Tensor