npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
RegularSampler1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_REGULARSAMPLER1D_HH_
2 #define NPSTAT_REGULARSAMPLER1D_HH_
3 
4 /*!
5 // \file RegularSampler1D.hh
6 //
7 // \brief Regular interval sampling in a manner that conforms
8 // to the AbsRandomGenerator interface
9 //
10 // Author: I. Volobouev
11 //
12 // March 2011
13 */
14 
16 
17 namespace npstat {
18  /**
19  // Simple regular sampler of the unit interval conforming to the
20  // AbsRandomGenerator interface. It first splits [0,1] into two equal
21  // intervals and returns the coordinate of the boundary (i.e., 0.5).
22  // Then it splits the two obtained intervals (the returned points are
23  // at 0.25 and 0.75). Then it splits the four intervals, then it splits
24  // the eight intervals, and so on. The coordinates of the boundaries
25  // are returned from left to right for each level of splitting.
26  */
28  {
29  public:
30  inline RegularSampler1D() {reset();}
31 
32  inline virtual ~RegularSampler1D() {}
33 
34  inline unsigned dim() const {return 1U;}
35  inline unsigned long long nCalls() const {return nCalls_;}
36 
37  double operator()();
38 
39  /** Reset to the initial state */
40  void reset();
41 
42  /**
43  // This method should be called to determine the number
44  // of generated points after which the interval will be
45  // uniformly sampled. The "level" can be 0, 1, 2, ..., 62.
46  */
47  static unsigned long long uniformCount(unsigned level);
48 
49  private:
50  long double intervalWidth_;
51  unsigned long long nIntervals_;
52  unsigned long long interval_;
53  unsigned long long nCalls_;
54  };
55 }
56 
57 #endif // NPSTAT_REGULARSAMPLER1D_HH_
Interface definition for pseudo- and quasi-random number generators.
Definition: RegularSampler1D.hh:28
static unsigned long long uniformCount(unsigned level)
unsigned dim() const
Definition: RegularSampler1D.hh:34
Definition: AbsArrayProjector.hh:14
Definition: AbsRandomGenerator.hh:27