ssmkit  master-68aed98
systematic.hpp
Go to the documentation of this file.
1 
7 #ifndef SSMPACK_FILTER_RESAMPLER_SYSTEMATIC
8 #define SSMPACK_FILTER_RESAMPLER_SYSTEMATIC
9 
12 
13 #include <armadillo>
14 
15 #include <random>
16 
17 namespace ssmkit {
18 namespace filter {
19 namespace resampler {
20 
23 template <class Criterion>
24 class Systematic : public BaseResampler<Systematic<Criterion>> {
25  friend class BaseResampler<Systematic<Criterion>>;
26 
27  private:
28  std::uniform_real_distribution<double> uniform_;
29 
30  protected:
31  arma::vec generateOrderedNumbers(const int &num_par) {
32  double u0 = uniform_(random::Generator::get().getGenerator());
33  arma::vec u(num_par);
34  int k = 0;
35  u.imbue([&u0, &num_par, &k]() { return (k++ + u0) / num_par; });
36  return u;
37  }
38 
39  public:
40  Systematic(Criterion criterion)
41  : BaseResampler<Systematic<Criterion>>(criterion) {}
42 };
43 
44 template<class Criterion>
46  return Systematic<Criterion>(criterion);
47 }
48 
49 } // namespace resampler
50 } // namespace filter
51 } // namespace ssmkit
52 #endif // SSMPACK_FILTER_RESAMPLER_SYSTEMATIC
Base resampling class.
Definition: base.hpp:23
static Generator & get()
Returns a reference to singleton instance.
Definition: generator.hpp:38
Implements systematic resampling method.
Definition: systematic.hpp:24
Systematic< Criterion > makeSystematic(Criterion criterion)
Definition: systematic.hpp:45
arma::vec generateOrderedNumbers(const int &num_par)
Definition: systematic.hpp:31