36 const auto n_steps = 10000;
37 const auto step_size = 0.1;
39 auto target_distribution = [](
double val) ->
double {
return std::pow(std::cos(val), 2.); };
41 auto current_angle = 0.;
44 for (
int i = 0; i < n_steps; ++i)
46 new_angle = rd_engine_->Gaus(current_angle, step_size);
48 if (new_angle < -ROOT::Math::Pi() || new_angle > ROOT::Math::Pi())
53 const auto acceptance_ratio = target_distribution(new_angle) / target_distribution(current_angle);
55 if (rd_engine_->Uniform(0.0, 1.0) < acceptance_ratio)
57 current_angle = new_angle;