npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
HOSobolGenerator.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_HOSOBOLGENERATOR_HH_
2 #define NPSTAT_HOSOBOLGENERATOR_HH_
3 
4 /*!
5 // \file HOSobolGenerator.hh
6 //
7 // \brief Generator of higher-order scrambled Sobol sequences
8 //
9 // Author: I. Volobouev
10 //
11 // October 2010
12 */
13 
15 
16 namespace npstat {
17  /**
18  // Generator of higher order scrambled Sobol sequences. The theory
19  // behind this method is described in http://arxiv.org/abs/1007.0842
20  //
21  // Sampling according to the points produced by this generator is
22  // supposed to achieve convergence rate of O(N^(-gamma-1/2+eps)),
23  // where "gamma" equals to min(interlacingFactor, alpha). Here, alpha is
24  // the maximum order of square-integrable continuous partial derivatives
25  // in the integrand, and "interlacingFactor" is a parameter of the
26  // scrambling algorithm. "eps" in the convergence rate stands for terms
27  // which look like log(N)^dim. For large N, "eps" becomes vanishingly
28  // small.
29  //
30  // The "interlacingFactor" parameter can not be made very high due to
31  // certain limitations in the algorithm implementation. The main problem
32  // is that, to construct scrambled random sequences with 2^k points,
33  // the algorithm is using integers with magnitudes up to
34  // 2^(interlacingFactor*k). This typically means that the product
35  // interlacingFactor*k can not be easily made larger than 64 on 64-bit
36  // systems. Therefore, if one uses interlacingFactor of 2, one can
37  // produce 2^32 quasi-random numbers, for interlacingFactor of 3 this
38  // becomes 2^21, for interlacingFactor of 4 this becomes 2^16, etc.
39  // Also, the dimensionality of the underlying Sobol sequence becomes
40  // larger than the dimensionality of the generated higher order sequence
41  // by the interlacing factor.
42  //
43  // If this generator is used with the "interlacingFactor" parameter of 1
44  // then it reproduces the original underlying Sobol sequence (which can
45  // have up to 2^62 points).
46  //
47  // The theoretical convergence rate claims should be taken with a grain
48  // of salt. In a simple numerical study which I did using multivariate
49  // exponentials, "interlacingFactor" value of 2 did provide significant
50  // improvement over the original Sobol sequence. "interlacingFactor"
51  // value of 3 worked significantly better than "interlacingFactor" of 2
52  // in 1 dimension, marginally better in 2 dimensions, and did not improve
53  // anything in 3 dimensions. "interlacingFactor" value of 4 worked
54  // marginally better than "interlacingFactor" of 3 in 1 dimension and
55  // did not improve anything in higher dimensions. Since big values of N
56  // can not be generated with this code for large interlacing factors,
57  // perhaps this just means that one needs to reach higher N in order to
58  // see the improvement due to scrambling. However, one can expect that
59  // in this case the limited precision of the integrand evaluation will
60  // become a dominant source of uncertainty and will spoil things anyway.
61  */
63  {
64  public:
65  HOSobolGenerator(unsigned dim, unsigned interlacingFactor,
66  unsigned maxPowerOfTwo, unsigned nSkip=0U);
67  inline virtual ~HOSobolGenerator() {}
68 
69  inline virtual unsigned dim() const {return dim_;}
70  virtual void run(double* buf, unsigned bufSize, unsigned nPoints);
71 
72  private:
73  long double normfactor_;
74  long long bitset_[DIM_MAX];
75  unsigned long long newset_[DIM_MAX];
76  unsigned dim_;
77  unsigned d_;
78  };
79 }
80 
81 #endif // NPSTAT_HOSOBOLGENERATOR_HH_
Generator of Sobol low-discrepancy sequences.
Definition: HOSobolGenerator.hh:63
virtual unsigned dim() const
Definition: HOSobolGenerator.hh:69
virtual void run(double *buf, unsigned bufSize, unsigned nPoints)
Definition: SobolGenerator.hh:23
Definition: AbsArrayProjector.hh:14