Skip to content

Commit

Permalink
added oversammpling method, reverted random device
Browse files Browse the repository at this point in the history
  • Loading branch information
OnionKiller committed Dec 4, 2020
1 parent e5553d6 commit 065a128
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
11 changes: 10 additions & 1 deletion EnvTest/src/Modell/rejection_sampling/impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void rejection_sampler::setModell(imperfect_virtualage_likelihood modell)

std::vector<double> rejection_sampler::solve(simulation_params param)
{
std::random_device gen;
std::default_random_engine gen;
auto U = std::bind(std::uniform_real_distribution(0., 1.),gen);
auto i = param.sample_size;
L_.set_data(failures_);
Expand Down Expand Up @@ -74,3 +74,12 @@ std::vector<double> rejection_sampler::estimate_result_()
std::for_each(avg.begin(), avg.end(), [accepted_number](double& param) {param = param / double(accepted_number); });
return avg;
}

void rejection_sampler::oversample(const unsigned int rate)
{
for (auto outer_incrementer = raw_result_.size()-1;outer_incrementer --> 0;)
{
for (auto i = rate; i-- > 0;)
raw_result_.push_back(raw_result_[outer_incrementer]);
}
}
1 change: 1 addition & 0 deletions EnvTest/src/Modell/rejection_sampling/impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ class rejection_sampler
//implement modell here
std::vector<sample_result> raw_result_;
std::vector<double> estimate_result_();
void oversample(const unsigned int rate);
};

0 comments on commit 065a128

Please sign in to comment.