<commit_before>// Copyright 2018 Google LLC. All Rights Reserved.
/*
  Copyright (C) 2009 <NAME>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

#ifndef BOOM_DISTRIBUTIONS_RNG_HPP
#define BOOM_DISTRIBUTIONS_RNG_HPP

// #include <boost/random/ranlux.hpp>
#include <random>

namespace BOOM {
  //  typedef boost::random::ranlux64_base_01 RNG;

  // A random number generator for simulating real valued U[0, 1) deviates.
  class RNG {
   public:
    // Seed with std::random_device.
    RNG();

    // Seed with a specified value.
    RNG(long seed);

    void seed();
    void seed(long seed) {generator_.seed(seed);}

    // Simulate a U[0, 1) random deviate.
    double operator()() {return dist_(generator_);}

    std::mt19937_64 & generator() {return generator_;}
    
   private:
    // TODO(steve): once you can use c++17 in R and elsewhere replace this with
    // a std::variant that will choose the fastest RNG for each implementation.
    std::mt19937_64 generator_;
    std::uniform_real_distribution<double> dist_;
  };

  
  struct GlobalRng {
   public:
    static RNG rng;
  };

  unsigned long seed_rng();  // generates a random seed from the global RNG
                             // used to seed other RNG's
  unsigned long seed_rng(RNG &);
}  // namespace BOOM

#endif  // BOOM_DISTRIBUTIONS_RNG_HPP<commit_msg>Improve comments in rng.hpp.<commit_after>// Copyright 2018 Google LLC. All Rights Reserved.
/*
  Copyright (C) 2009 <NAME>

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
*/

#ifndef BOOM_DISTRIBUTIONS_RNG_HPP
#define BOOM_DISTRIBUTIONS_RNG_HPP

// #include <boost/random/ranlux.hpp>
#include <random>

namespace BOOM {
  //  typedef boost::random::ranlux64_base_01 RNG;

  // A random number generator for simulating real valued U[0, 1) deviates.
  class RNG {
   public:
    // Seed with std::random_device.
    RNG();

    // Seed with a specified value.
    RNG(long seed);

    // Seed from a C++ standard random device, if one is present.
    void seed();

    // Seed using a specified value.
    void seed(long seed) {generator_.seed(seed);}

    // Simulate a U[0, 1) random deviate.
    double operator()() {return dist_(generator_);}

    std::mt19937_64 & generator() {return generator_;}
    
   private:
    // TODO(steve): once you can use c++17 in R and elsewhere replace this with
    // a std::variant that will choose the fastest RNG for each implementation.
    std::mt19937_64 generator_;
    std::uniform_real_distribution<double> dist_;
  };

  // The GlobalRng is a singleton.
  struct GlobalRng {
   public:
    static RNG rng;
  };

  unsigned long seed_rng();  // generates a random seed from the global RNG
                             // used to seed other RNG's
  unsigned long seed_rng(RNG &);
}  // namespace BOOM

#endif  // BOOM_DISTRIBUTIONS_RNG_HPP
{'fraction_non_alphanumeric': 0.0799616949964089, 'fraction_numerical': 0.021546564519990423, 'mean_word_length': 3.2074521651560928, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5732997', 'n_tokens_mistral': 1298, 'n_tokens_neox': 1192, 'n_words': 511}