| 
    SST/macro
    
   | 
 
A subtract with borrow random number generator by George Marsaglia (1999; internet posting). More...
#include <rng.h>


Public Member Functions | |
| virtual std::string | to_string () const | 
| rngint_t | value () | 
| ~SWB () | |
| void | vec_reseed (const std::vector< rngint_t > &seeds) | 
| int | nseed () | 
  Public Member Functions inherited from RNG::Table256 | |
| ~Table256 () | |
  Public Member Functions inherited from RNG::UniformInteger | |
| virtual | ~UniformInteger () | 
| rngint_t | value_in_range (rngint_t range) | 
| virtual double | realvalue (bool include_zero=true, bool include_one=true) | 
| Return a random value in the interval [0,1], (0,1], [0,1), or (0,1)  More... | |
| void | reseed () | 
| void | reseed (rngint_t) | 
| void | reseed (rngint_t, rngint_t) | 
| void | reseed (rngint_t, rngint_t, rngint_t) | 
| void | reseed (rngint_t, rngint_t, rngint_t, rngint_t) | 
Static Public Member Functions | |
| static SWB * | construct () | 
| static SWB * | construct (const std::vector< rngint_t > &) | 
Protected Member Functions | |
| SWB () | |
  Protected Member Functions inherited from RNG::Table256 | |
| Table256 () | |
Private Attributes | |
| rngint_t | x | 
| rngint_t | y | 
Additional Inherited Members | |
  Protected Attributes inherited from RNG::Table256 | |
| UniformInteger * | seeder_ | 
| rngint_t | t [256] | 
| unsigned char | c | 
A subtract with borrow random number generator by George Marsaglia (1999; internet posting).
Here is an excerpt from the posting describing this generator: SWB is a subtract-with-borrow generator that I developed to give a simple method for producing extremely long periods: x(n)=x(n-222)-x(n-237)-borrow mod 232. The 'borrow' is 0 unless set to 1 if computing x(n-1) caused overflow in 32-bit integer arithmetic. This generator has a very long period, 27098(2480-1), about 27578. It seems to pass all tests of randomness, but, suspicious of a generator so simple and fast (62 nanosecs at 300MHz), I would suggest combining SWB with KISS, MWC, SHR3, or CONG.
      
  | 
  protected | 
| RNG::SWB::~SWB | ( | ) | 
      
  | 
  static | 
      
  | 
  virtual | 
Reimplemented from RNG::Table256.
      
  | 
  inlinevirtual | 
Definition at line 461 of file rng.h.
References RNG::UniformInteger::nseed(), RNG::UniformInteger::value(), and RNG::UniformInteger::vec_reseed().

      
  | 
  virtual | 
Implements RNG::UniformInteger.
      
  | 
  virtual | 
Reimplemented from RNG::Table256.
 1.8.11