|
EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
|
Chooses index i floor( \( M w_i / \sum w \)) times deterministically, then draws the remainder with Inner from the fractional parts.
More...
#include <EmrysFilter/Core/Resampling.h>
Public Member Functions | |
| template<std::floating_point Scalar, std::uniform_random_bit_generator G> | |
| void | operator() (std::span< Scalar const > weights, std::span< Eigen::Index > ancestors, G &rng, std::span< Scalar > scratch) const |
Fills ancestors with floor( \( M w_i / \sum w \)) copies of each index i, then draws the rest with fractional from the fractional parts, using rng. | |
| template<std::floating_point Scalar, std::uniform_random_bit_generator G> | |
| void | operator() (std::span< Scalar const > weights, std::span< Eigen::Index > ancestors, G &rng) const |
| As the form with scratch, allocating the scratch. | |
| template<ExecutionPolicy P, std::floating_point Scalar, std::uniform_random_bit_generator G> | |
| void | operator() (P &&policy, std::span< Scalar const > weights, std::span< Eigen::Index > ancestors, G &rng) const |
| As the sequential form, under policy: the total is a reduction, each index's copies and fraction a for-each, and the copies are placed by a scan of their counts. | |
Public Attributes | |
| Inner | fractional {} |
| the resampler for the remainder, applied to the fractional parts | |
Chooses index i floor( \( M w_i / \sum w \)) times deterministically, then draws the remainder with Inner from the fractional parts.
Residual resampling (Liu and Chen (1998)), as given in Douc, Cappé, and Moulines (2005), §2.2, equations (4) and (5): the integer parts are deterministic, and only the \( M - \sum_i \lfloor M w_i / \sum w \rfloor \) remaining ancestors are random.
|
inline |
As the sequential form, under policy: the total is a reduction, each index's copies and fraction a for-each, and the copies are placed by a scan of their counts.
The remainder is drawn by fractional under policy if it runs under one. Under Sequential it is the sequential form.
|
inline |
Fills ancestors with floor( \( M w_i / \sum w \)) copies of each index i, then draws the rest with fractional from the fractional parts, using rng.
The fractional parts are kept in scratch, which has at least weights.size() + ancestors.size() elements; what follows them is residual's scratch, if it takes any.