Alexandria 2.31.0
SDC-CH common library for the Euclid project
|
#include <NdSampler.h>
Public Member Functions | |
NdSampler (std::tuple< std::vector< TKnot >... > knots, const NdArray::NdArray< double > &grid) | |
template<typename Generator > | |
std::vector< std::tuple< TKnot... > > | draw (std::size_t ndraws, Generator &rng) const |
template<typename Generator , typename... OKnots> | |
void | draw (std::size_t ndraws, Generator &rng, std::vector< std::tuple< OKnots... > > &output) const |
Multidimensional sampler Inspired on
S. Dolgov, K. Anaya-Izquierdo, C. Fox, and R. Scheichl, "Approximation and sampling of multivariate probability distributions in the tensor train decomposition” See Section 2
NdSampler recursively decomposes the sampling of a N dimensional space into sampling from an N-1 dimensional space (marginalized), and then sampling the N dimension according to p(x_n|x_1,...,x{n-1}) As specified on the cited paper, the conditional can be approximated by p(x_1,...,x{n-1},x_n), which is computed using the N-dimensional interpolation of the grid for each $x_n \in knots_n$.
N | The number of dimensions |
Definition at line 48 of file NdSampler.h.
Euclid::MathUtils::NdSampler< TKnot >::NdSampler | ( | std::tuple< std::vector< TKnot >... > | knots, |
const NdArray::NdArray< double > & | grid | ||
) |
Constructor
knots | Dimensions of the n-dimensional grid. The first coordinate axis corresponds to the faster changing index on the grid (last one), and the last to the slowest axis (first one). This is compatible with the GridContainer internal memory layout |
grid | Values of the PDF at each grid intersection. |
std::vector< std::tuple< TKnot... > > Euclid::MathUtils::NdSampler< TKnot >::draw | ( | std::size_t | ndraws, |
Generator & | rng | ||
) | const |
Draw samples from the n-dimensional distribution
Generator | Type of the random number generator (i.e std::mt19937) |
ndraws | Number of samples |
rng | Instance of the random number generator |
void Euclid::MathUtils::NdSampler< TKnot >::draw | ( | std::size_t | ndraws, |
Generator & | rng, | ||
std::vector< std::tuple< OKnots... > > & | output | ||
) | const |