Skip to content

Commit

Permalink
Change RNG to boost::mixmax
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Feb 8, 2024
1 parent b6d010f commit 7fdd2c3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/stan/services/util/create_rng.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef STAN_SERVICES_UTIL_CREATE_RNG_HPP
#define STAN_SERVICES_UTIL_CREATE_RNG_HPP

#include <boost/random/additive_combine.hpp>
#include <boost/random/mixmax.hpp>

namespace stan {

using rng_t = boost::ecuyer1988;
using rng_t = boost::random::mixmax;

namespace services {
namespace util {
Expand All @@ -26,12 +26,7 @@ namespace util {
* @return an stan::rng_t instance
*/
inline rng_t create_rng(unsigned int seed, unsigned int chain) {
using boost::uintmax_t;
static constexpr uintmax_t DISCARD_STRIDE = static_cast<uintmax_t>(1) << 50;
rng_t rng(seed);
// always discard at least 1 to avoid issue with small seeds for certain RNG
// distributions. See stan#3167 and boostorg/random#92
rng.discard(std::max(static_cast<uintmax_t>(1), DISCARD_STRIDE * chain));
rng_t rng(seed + chain);
return rng;
}

Expand Down

0 comments on commit 7fdd2c3

Please sign in to comment.