Simpatico  v1.10
Ar1Process.h
1 #ifndef UTIL_AR1_PROCESS_H
2 #define UTIL_AR1_PROCESS_H
3 
4 /*
5 * Util Package - C++ Utilities for Scientific Computation
6 *
7 * Copyright 2010 - 2017, The Regents of the University of Minnesota
8 * Distributed under the terms of the GNU General Public License.
9 */
10 
11 #include <util/random/Random.h>
12 #include <cmath>
13 
14 namespace Util
15 {
16 
27  class Ar1Process
28  {
29 
30  public:
31 
35  Ar1Process();
36 
42  Ar1Process(Random& random);
43 
49  void setRNG(Random& random);
50 
56  void init(double tau);
57 
61  double operator () ();
62 
63  private:
64 
65  double x_;
66 
67  double B_;
68 
69  double C_;
70 
71  Random* randomPtr_;
72 
73  bool isInitialized_;
74 
75  };
76 
77  inline double Ar1Process::operator() ()
78  {
79  assert(isInitialized_);
80  x_ *= C_;
81  x_ += B_*randomPtr_->gaussian();
82  return x_;
83  }
84 
85 }
86 #endif
double operator()()
Generate and return a new value.
Definition: Ar1Process.h:77
Generator for a discrete AR(1) Markov process.
Definition: Ar1Process.h:27
Utility classes for scientific computation.
Definition: accumulators.mod:1
double gaussian(void)
Return a Gaussian random number with zero average and unit variance.
Definition: Random.cpp:92
void setRNG(Random &random)
Associate a random number generator.
Definition: Ar1Process.cpp:38
Ar1Process()
Constructor.
Definition: Ar1Process.cpp:16
Random number generator.
Definition: Random.h:46
void init(double tau)
Initialize process.
Definition: Ar1Process.cpp:46