autoppl  v0.8
A C++ template library for probabilistic programming
sampler_tools.hpp
Go to the documentation of this file.
1 #pragma once
2 #include <chrono>
3 
4 namespace ppl {
5 namespace mcmc {
6 
10 inline size_t random_seed()
11 {
12  return std::chrono::duration_cast<std::chrono::milliseconds>
13  (std::chrono::system_clock::now().time_since_epoch()).count();
14 }
15 
21 template <class UniformDistType, class GenType>
22 inline bool accept_or_reject(double p,
23  UniformDistType&& unif_sampler,
24  GenType&& gen)
25 {
26  return (unif_sampler(gen) <= p);
27 }
28 
29 } // namespace mcmc
30 } // namespace ppl
ppl::mcmc::random_seed
size_t random_seed()
Definition: sampler_tools.hpp:10
ppl
Definition: bounded.hpp:11
ppl::mcmc::accept_or_reject
bool accept_or_reject(double p, UniformDistType &&unif_sampler, GenType &&gen)
Definition: sampler_tools.hpp:22