EmrysFilter 0.1.0
State estimation utilities in C++23 using Eigen
Loading...
Searching...
No Matches
Emrys::upkeep::Resample< G, Resampler_, Policy_ > Class Template Reference

Action that resamples a set in proportion to its weights, drawing from the generator G with the resampler Resampler_ (systematic by default) under the execution policy Policy_ (sequential by default), to a given size if one is given and to the set's size otherwise. More...

#include <EmrysFilter/Distributions/Upkeep.h>

Public Member Functions

constexpr Resample (G &generator, Resampler_ resampler={}, std::optional< Eigen::Index > size=std::nullopt, Policy_ policy={})
 Draws from generator with resampler under policy, to size particles if one is given and to the state's size otherwise.
template<typename State>
requires internal::ResamplableBy<State, G, Resampler_, Policy_>
std::expected< bool, WeightError > operator() (State &state) const
 Resamples state.
constexpr G & generator () const noexcept
constexpr Resampler_ const & resampler () const noexcept
constexpr std::optional< Eigen::Index > size () const noexcept
constexpr Policy_ const & policy () const noexcept

Detailed Description

template<std::uniform_random_bit_generator G, typename Resampler_ = resamplers::Systematic, ExecutionPolicy Policy_ = execution::Sequential>
class Emrys::upkeep::Resample< G, Resampler_, Policy_ >

Action that resamples a set in proportion to its weights, drawing from the generator G with the resampler Resampler_ (systematic by default) under the execution policy Policy_ (sequential by default), to a given size if one is given and to the set's size otherwise.

The state is anything with resample(rng, newSize, resampler) and size(), or under a policy other than execution::sequential resample(policy, rng, newSize, resampler), such as a ParticleSet or a ParticleGaussianParams; its weights become equal. A size lets upkeep change the particle count. A caller computing the count from the state, as KLD sampling does, makes the action at each step, since an action is a small value. The action holds a reference to the generator, which must outlive it, and draws from it at each call; a generator made in the call to resample() does not compile.

See also
WhenEss, Resamplers

Member Function Documentation

◆ generator()

template<std::uniform_random_bit_generator G, typename Resampler_ = resamplers::Systematic, ExecutionPolicy Policy_ = execution::Sequential>
G & Emrys::upkeep::Resample< G, Resampler_, Policy_ >::generator ( ) const
inlinenodiscardconstexprnoexcept
Returns
the generator drawn from

◆ operator()()

template<std::uniform_random_bit_generator G, typename Resampler_ = resamplers::Systematic, ExecutionPolicy Policy_ = execution::Sequential>
template<typename State>
requires internal::ResamplableBy<State, G, Resampler_, Policy_>
std::expected< bool, WeightError > Emrys::upkeep::Resample< G, Resampler_, Policy_ >::operator() ( State & state) const
inlinenodiscard

Resamples state.

Returns
true, or the WeightError of the state's resample()

◆ policy()

template<std::uniform_random_bit_generator G, typename Resampler_ = resamplers::Systematic, ExecutionPolicy Policy_ = execution::Sequential>
Policy_ const & Emrys::upkeep::Resample< G, Resampler_, Policy_ >::policy ( ) const
inlinenodiscardconstexprnoexcept
Returns
the execution policy

◆ resampler()

template<std::uniform_random_bit_generator G, typename Resampler_ = resamplers::Systematic, ExecutionPolicy Policy_ = execution::Sequential>
Resampler_ const & Emrys::upkeep::Resample< G, Resampler_, Policy_ >::resampler ( ) const
inlinenodiscardconstexprnoexcept
Returns
the resampler (see Resamplers)

◆ size()

template<std::uniform_random_bit_generator G, typename Resampler_ = resamplers::Systematic, ExecutionPolicy Policy_ = execution::Sequential>
std::optional< Eigen::Index > Emrys::upkeep::Resample< G, Resampler_, Policy_ >::size ( ) const
inlinenodiscardconstexprnoexcept
Returns
the size resampled to, or none to keep the state's

The documentation for this class was generated from the following file: