Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template sobol_engine

boost::random::sobol_engine

Synopsis

// In header: <boost/random/sobol.hpp>

template<typename UIntType,  w, 
         typename SobolTables = default_sobol_table> 
class sobol_engine {
public:
  // types
  typedef UIntType ;

  // construct/copy/destruct
  ();

  // public member functions
   () ;
  void ();
  void (UIntType);
  result_type ();
  void (boost::uintmax_t);

  // public static functions
  constexpr result_type ();
  constexpr result_type ();

  // friend functions
  bool (const sobol_engine &, const sobol_engine &);
  bool (const sobol_engine &, const sobol_engine &);
  template<typename CharT, typename Traits> 
    CharT, Traits > & 
    (CharT, Traits > &, const sobol_engine &);
  template<typename CharT, typename Traits> 
    CharT, Traits > & 
    (CharT, Traits > &, const sobol_engine &);
};

Description

Instantiations of class template sobol_engine model a quasi-random number generator . The sobol_engine uses the algorithm described in

[Bratley+Fox, TOMS 14, 88 (1988)] and [Antonov+Saleev, USSR Comput. Maths. Math. Phys. 19, 252 (1980)]

[Note] Note

sobol_engine skips trivial zeroes at the start of the sequence. For example, the beginning of the 2-dimensional Sobol sequence in uniform_01 distribution will look like this:

In the following documentation X denotes the concrete class of the template sobol_engine returning objects of type UIntType, u and v are the values of X.

Some member functions may throw exceptions of type std::range_error. This happens when the quasi-random domain is exhausted and the generator cannot produce any more values. The length of the low discrepancy sequence is given by .

sobol_engine public construct/copy/destruct

  1. ( s);

    Effects: Constructs the default s-dimensional Sobol quasi-random number generator.

    Throws: bad_alloc, invalid_argument, range_error.

sobol_engine public member functions

  1.  () ;

    Returns: The dimension of of the quasi-random domain.

    Throws: nothing.

  2. void ();
    Throws: nothing.

    Effects: Resets the quasi-random number generator state to the one given by the default construction. Equivalent to u.seed(0).

  3. void (UIntType init);
    Throws: range_error.

    Effects: Effectively sets the quasi-random number generator state to the init-th vector in the s-dimensional quasi-random domain, where s == X::dimension().

  4. result_type ();

    Returns: Returns a successive element of an s-dimensional (s = X::dimension()) vector at each invocation. When all elements are exhausted, X::operator() begins anew with the starting element of a subsequent s-dimensional vector.

    Throws: range_error.

  5. void (boost::uintmax_t z);

    Effects: Advances *this state as if z consecutive X::operator() invocations were executed.

    Throws: range_error.

sobol_engine public static functions

  1. constexpr result_type ();

    Returns: Tight lower bound on the set of values returned by operator().

    Throws: nothing.

  2. constexpr result_type ();

    Returns: Tight upper bound on the set of values returned by operator().

    Throws: nothing.

sobol_engine friend functions

  1. bool (const sobol_engine & x, const sobol_engine & y);

    Returns true if the two generators will produce identical sequences of outputs.

  2. bool (const sobol_engine & lhs, const sobol_engine & rhs);

    Returns true if the two generators will produce different sequences of outputs.

  3. template<typename CharT, typename Traits> 
      CharT, Traits > & 
      (CharT, Traits > & os, const sobol_engine & s);

    Writes the textual representation of the generator to a std::ostream.

  4. template<typename CharT, typename Traits> 
      CharT, Traits > & 
      (CharT, Traits > & is, const sobol_engine & s);

    Reads the textual representation of the generator from a std::istream.


PrevUpHomeNext