13 using namespace Eigen;
17 generator_(std::mt19937_64(seed))
27 generator_(resampling.generator_)
32 generator_(std::move(resampling.generator_))
39 *
this = std::move(tmp);
47 if (
this == &resampling)
50 generator_ = std::move(resampling.generator_);
58 if (
this == &resampling)
61 generator_ = std::move(resampling.generator_);
68 Ref<VectorXi> res_parents)
70 int num_particles =
static_cast<int>(cor_particles.
weight().rows());
71 VectorXd csw(num_particles);
73 csw(0) = exp(cor_particles.
weight(0));
74 for (
int i = 1; i < num_particles; ++i)
75 csw(i) = csw(i-1) + exp(cor_particles.
weight(i));
77 std::uniform_real_distribution<double> distribution_res(0.0, 1.0/num_particles);
78 double u_1 = distribution_res(generator_);
81 for (
int j = 0; j < num_particles; ++j)
83 double u_j = u_1 +
static_cast<double>(j)/num_particles;
85 while (u_j > csw(idx_csw) && idx_csw < (num_particles - 1))
88 res_particles.
state(j) = cor_particles.
state(idx_csw);
89 res_particles.
mean(j) = cor_particles.
mean(idx_csw);
91 res_particles.
weight(j) = -std::log(num_particles);
92 res_parents(j) = idx_csw;
99 return 1.0/cor_weights.array().exp().square().sum();