template class mrpt::bayes::CRejectionSamplingCapable

Overview

A base class for implementing rejection sampling in a generic state space.

See the main method CRejectionSamplingCapable::rejectionSampling To use this class, create your own class as a child of this one and implement the desired virtual methods, and add any required internal data.

#include <mrpt/bayes/CRejectionSamplingCapable.h>

template <
    class TStateSpace,
    mrpt::bayes::particle_storage_mode STORAGE = mrpt::bayes::particle_storage_mode::POINTER
    >
class CRejectionSamplingCapable
{
public:
    // methods

    void rejectionSampling(
        size_t desiredSamples,
        std::vector<TParticle>& outSamples,
        size_t timeoutTrials = 1000
        );
};

// direct descendants

class CRejectionSamplingRangeOnlyLocalization;

Methods

void rejectionSampling(
    size_t desiredSamples,
    std::vector<TParticle>& outSamples,
    size_t timeoutTrials = 1000
    )

Generates a set of N independent samples via rejection sampling.

Parameters:

desiredSamples

The number of desired samples to generate

outSamples

The output samples.

timeoutTrials

The maximum number of rejection trials for each generated sample (i.e. the maximum number of iterations). This can be used to set a limit to the time complexity of the algorithm for difficult probability densities. All will have equal importance weights (a property of rejection sampling), although those samples generated at timeout will have a different importance weights.