ssmkit  master-68aed98
memoryless.hpp
Go to the documentation of this file.
1 
7 #ifndef SSMPACK_PROCESS_MEMORYLESS_HPP
8 #define SSMPACK_PROCESS_MEMORYLESS_HPP
9 
12 
13 #include <algorithm>
14 #include <cmath>
15 #include <type_traits>
16 #include <vector>
17 
18 namespace ssmkit {
19 namespace process {
20 
27 template <typename TPDF, typename TParamMap>
28 class Memoryless : public BaseProcess<Memoryless<TPDF, TParamMap>> {
29  private:
32 
33  public:
34 
46  : cpdf_(std::move(cpdf)) {}
47 
48 
56  auto initialize() -> decltype(std::declval<TPDF>().random()) {
57  /* memoryless doesn't have sensible initialization so initialize simply
58  * returns the default value of the random variable type.
59  */
60  decltype(std::declval<TPDF>().random()) rv;
61  return rv;
62  }
63 
71  template <typename... Args>
72  auto random(const Args &... args) -> decltype(std::declval<TPDF>().random()) {
73  return cpdf_.random(args...);
74  }
75 
85  template <typename... Args>
86  double likelihood(const decltype(std::declval<TPDF>().random()) &rv,
87  const Args &... args) {
88  return cpdf_.likelihood(rv, args...);
89  }
90 
93  getCPDF() {return cpdf_;}
94 };
95 
102 template <typename TPDF, typename TParamMap>
103 Memoryless<TPDF, TParamMap>
105  return Memoryless<TPDF, TParamMap>(cpdf);
106 }
107 
108 } // namespace process
109 } // namespace ssmkit
110 
111 #endif // SSMPACK_PROCESS_MEMORYLESS_HPP
Memoryless< TPDF, TParamMap > makeMemoryless(distribution::Conditional< TPDF, TParamMap > cpdf)
Convenient builder for Memoryless process.
Definition: memoryless.hpp:104
Conditional distribution function.
Definition: conditional.hpp:34
auto random(const Args &...args) -> decltype(std::declval< TPDF >().random())
Sample from process.
Definition: memoryless.hpp:72
distribution::Conditional< TPDF, TParamMap > & getCPDF()
Returns a reference to internal CPDF.
Definition: memoryless.hpp:93
A Memoryless (independent/white) random process.
Definition: memoryless.hpp:28
Memoryless(distribution::Conditional< TPDF, TParamMap > cpdf)
Constructor.
Definition: memoryless.hpp:45
auto initialize() -> decltype(std::declval< TPDF >().random())
initialize process
Definition: memoryless.hpp:56
double likelihood(const decltype(std::declval< TPDF >().random())&rv, const Args &...args)
Calculate likelihood.
Definition: memoryless.hpp:86