1 //                                               -*- C++ -*-
2 /**
3  *  @brief A class which implements the RandomWalk process
4  *
5  *  Copyright 2005-2021 Airbus-EDF-IMACS-ONERA-Phimeca
6  *
7  *  This library is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 #ifndef OPENTURNS_RANDOMWALK_HXX
22 #define OPENTURNS_RANDOMWALK_HXX
23 
24 #include "openturns/ProcessImplementation.hxx"
25 #include "openturns/Process.hxx"
26 #include "openturns/Pointer.hxx"
27 #include "openturns/Distribution.hxx"
28 #include "openturns/Point.hxx"
29 
30 BEGIN_NAMESPACE_OPENTURNS
31 
32 /**
33  * @class RandomWalk
34  *
35  * An interface class for composite White Noise
36  */
37 class OT_API RandomWalk
38   : public ProcessImplementation
39 {
40   CLASSNAME
41 
42 public:
43 
44   /** Default constructor */
45   RandomWalk();
46 
47   /** Standard constructor */
48   RandomWalk(const Point & origin,
49              const Distribution & distribution);
50 
51   /** Standard constructor */
52   RandomWalk(const Point & origin,
53              const Distribution & distribution,
54              const RegularGrid & timeGrid);
55 
56   /** Virtual constructor */
57   RandomWalk * clone() const override;
58 
59   /** String converter */
60   String __repr__() const override;
61 
62   /** String converter */
63   String __str__(const String & offset = "") const override;
64 
65   /** Is the underlying stationary ? */
66   Bool isStationary() const override;
67 
68   /** Is the underlying a Gaussian process ? */
69   Bool isNormal() const override;
70 
71   /** Realization accessor */
72   Field getRealization() const override;
73 
74   /** Continuation of the last realization on a given number of steps */
75   using ProcessImplementation::getFuture;
76   TimeSeries getFuture(const UnsignedInteger stepNumber) const override;
77 
78   /** Get the marginal process corresponding to indices components */
79   Process getMarginal(const Indices & indices) const override;
80 
81   /** Distribution accessor */
82   Distribution getDistribution() const;
83 
84   /** Distribution accessor */
85   void setDistribution(const Distribution & distribution);
86 
87   /** Origin accessor */
88   Point getOrigin() const;
89 
90   /** Origin accessor */
91   void setOrigin(const Point & origin);
92 
93   /** Mesh accessor */
94   void setMesh(const Mesh & mesh) override;
95 
96   /** Method save() stores the object through the StorageManager */
97   void save(Advocate & adv) const override;
98 
99   /** Method load() reloads the object from the StorageManager */
100   void load(Advocate & adv) override;
101 
102 private:
103 
104   /** The origin of the walk */
105   Point origin_;
106 
107   /** The distribution of the walk steps */
108   Distribution distribution_;
109 
110   /** The current position of the walk */
111   mutable Point currentPosition_;
112 
113 }; /* class RandomWalk */
114 
115 END_NAMESPACE_OPENTURNS
116 
117 #endif /* OPENTURNS_RANDOMWALK_HXX */
118