Sampling
__all__ = ['AbstractSampler', 'AbstractEuclideanSampler', 'GaussianSampler', 'FibonacciGridSampler', 'FibonacciRejectionSampler', 'SobolGridSampler', 'HaltonGridSampler', 'get_grid_hypersphere', 'CircularUniformSampler', 'AbstractHypersphericalUniformSampler', 'AbstractSphericalUniformSampler', 'SphericalFibonacciSampler', 'AbstractHopfBasedS3Sampler', 'HealpixHopfSampler', 'FibonacciHopfSampler', 'LeopardiSampler', 'JulierSigmaPoints', 'MerweScaledSigmaPoints']
module-attribute
AbstractSampler
Bases: ABC
sample_stochastic(n_samples, dim)
abstractmethod
AbstractEuclideanSampler
Bases: AbstractSampler
FibonacciGridSampler
Bases: AbstractEuclideanSampler
Deterministic Gaussian sampler using multi-dimensional Fibonacci grids.
Implements the Fibonacci grid sampling from: Frisch and Hanebeck, "Deterministic Gaussian Sampling With Generalized Fibonacci Grids", FUSION 2021.
sample_stochastic returns moment-matched standard normal Fibonacci grid
samples on R^D. Despite the method name the samples are deterministic.
sample_stochastic(n_samples, dim)
Return moment-matched standard normal Fibonacci grid samples.
Despite the name, these are deterministic samples.
Parameters
n_samples : int Number of samples. dim : int Dimension of the Euclidean space.
Returns
np.ndarray of shape (n_samples, dim)
get_gaussian_samples(n_samples, dim, covariance=None, mean=None)
Return Fibonacci grid samples transformed to a Gaussian distribution.
Parameters
n_samples : int Number of samples. dim : int Dimension of the Euclidean space. covariance : np.ndarray of shape (dim, dim), optional Covariance matrix. Defaults to identity. mean : np.ndarray of shape (dim,), optional Mean vector. Defaults to zeros.
Returns
np.ndarray of shape (n_samples, dim)
get_uniform_samples(n_samples, dim)
Return Fibonacci grid samples uniform on [0, 1]^dim.
Parameters
n_samples : int Number of samples. dim : int Dimension of the Euclidean space.
Returns
np.ndarray of shape (n_samples, dim)
FibonacciRejectionSampler
Bases: AbstractEuclideanSampler
Deterministic rejection sampler using Fibonacci proposal grids.
sample_stochastic(n_samples, dim)
sample_rejection(pdf, n_candidates, dim, max_density, *, bounding_box=None)
Sample an arbitrary bounded density with deterministic Fibonacci proposals.
Parameters
pdf : callable
Density function accepting an array of shape (n_candidates, dim).
n_candidates : int
Number of deterministic proposal points before rejection.
dim : int
Dimension of the Euclidean domain.
max_density : float
Upper bound on pdf inside the bounding box.
bounding_box : np.ndarray of shape (dim, 2), optional
Lower and upper bounds for each dimension. Defaults to the unit hypercube.
Returns
samples : np.ndarray of shape (n_accepted, dim) Accepted samples. info : dict Rejection metadata.
GaussianSampler
Bases: AbstractEuclideanSampler
sample_stochastic(n_samples, dim)
HaltonGridSampler
Bases: _QMCProposalGridSampler
Deterministic Halton proposal grid on the Euclidean unit hypercube.
SobolGridSampler
Bases: _QMCProposalGridSampler
Deterministic Sobol proposal grid on the Euclidean unit hypercube.
AbstractHopfBasedS3Sampler
Bases: AbstractHypersphericalUniformSampler
hopf_coordinates_to_quaterion_yershova(θ, φ, ψ)
staticmethod
One possible way to index the S3-sphere via the hopf fibration. Using the convention from "Generating Uniform Incremental Grids on SO(3) Using the Hopf Fibration" by Anna Yershova, Swati Jain, Steven M. LaValle, Julie C. Mitchell As in appendix (or in Eq 4 if one reorders it).
quaternion_to_hopf_yershova(q)
staticmethod
AbstractHypersphericalUniformSampler
Bases: AbstractSampler
sample_stochastic(n_samples, dim)
get_grid(grid_density_parameter, dim)
abstractmethod
AbstractSphericalUniformSampler
Bases: AbstractHypersphericalUniformSampler
sample_stochastic(n_samples, dim=2)
FibonacciHopfSampler
Bases: AbstractHopfBasedS3Sampler
get_grid(grid_density_parameter, dim=3)
Hopf coordinates are (θ, ϕ, ψ) where θ and ϕ are the angles for the sphere and ψ is the angle on the circle First parameter is the number of points on the sphere, second parameter is the number of points on the circle.
HealpixHopfSampler
Bases: AbstractHopfBasedS3Sampler
get_grid(grid_density_parameter, dim=3)
Hopf coordinates are (θ, ϕ, ψ) where θ and ϕ are the angles for the sphere and ψ is the angle on the circle First parameter is the number of points on the sphere, second parameter is the number of points on the circle.
LeopardiSampler
Bases: AbstractHypersphericalUniformSampler
original_code_column_order = original_code_column_order
instance-attribute
__init__(original_code_column_order=True)
get_grid(grid_density_parameter, dim)
SphericalFibonacciSampler
Bases: AbstractSphericalCoordinatesBasedSampler
get_grid_spherical_coordinates(grid_density_parameter)
CircularUniformSampler
Bases: AbstractCircularSampler
sample_stochastic(n_samples, dim=1)
get_grid(grid_density_parameter)
Returns an equidistant grid of points on the circle [0,2*pi).
JulierSigmaPoints
Julier sigma points (Julier and Uhlmann, 1997).
Parameters
n:
State dimension.
kappa:
Scaling parameter (n + kappa should be non-zero).
n = n
instance-attribute
kappa = kappa
instance-attribute
__init__(n, kappa=0.0)
sigma_points(x, P)
Return (2n+1, n) sigma-point matrix.
Parameters
x:
State mean, shape (n,).
P:
State covariance, shape (n, n).
MerweScaledSigmaPoints
Merwe scaled sigma points (van der Merwe, 2004).
Parameters
n: State dimension. alpha: Spread of sigma points around the mean (typically 1e-3). beta: Prior knowledge of the distribution (2 is optimal for Gaussians). kappa: Secondary scaling parameter (typically 0).
n = n
instance-attribute
alpha = alpha
instance-attribute
beta = beta
instance-attribute
kappa = kappa
instance-attribute
__init__(n, alpha, beta, kappa)
sigma_points(x, P)
Return (2n+1, n) sigma-point matrix.
Parameters
x:
State mean, shape (n,).
P:
State covariance, shape (n, n).