KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
likelihood_dynamics.h
Go to the documentation of this file.
1 
2 /* $Id: likelihood_dynamics.h 18278 2014-11-25 01:42:10Z ksimek $ */
3 
4 /* =========================================================================== *
5 |
6 | Copyright (c) 1994-2008 by Kobus Barnard (author).
7 |
8 | Personal and educational use of this code is granted, provided that this
9 | header is kept intact, and that the authorship is not misrepresented, that
10 | its use is acknowledged in publications, and relevant papers are cited.
11 |
12 | For other use contact the author (kobus AT cs DOT arizona DOT edu).
13 |
14 | Please note that the code in this file has not necessarily been adequately
15 | tested. Naturally, there is no guarantee of performance, support, or fitness
16 | for any particular task. Nonetheless, I am interested in hearing about
17 | problems that you encounter.
18 |
19 | Author: Luca Del Pero
20 * =========================================================================== */
21 
22 #ifndef LIKELIHOOD_DYNAMICS_INCLUDED
23 #define LIKELIHOOD_DYNAMICS_INCLUDED
24 
26 #include <boost/function.hpp>
27 #include <boost/bind.hpp>
28 #include <l_cpp/l_int_matrix.h>
29 
30 namespace kjb {
31 
39 {
40 public:
41 
51  Likelihood_dynamics(double ialpha = 0.99, unsigned int ikick = 0) :
52  Abstract_dynamics(ialpha, ikick)
53  {
54 
55  }
56 
70  (
71  kjb::Vector iparameters,
72  kjb::Vector ideltas,
73  kjb::Vector ietas,
74  double ialpha = 0.99,
75  unsigned int ikick = 0
76  ) : Abstract_dynamics(iparameters, ideltas, ialpha, ikick)
77  {
78  if(ietas.size() != iparameters.size())
79  {
80  KJB_THROW_2(Illegal_argument, "The number of eta steps does not match the number of parameters");
81  }
82  etas = ietas;
83  }
84 
86 
88 
89  virtual ~Likelihood_dynamics() { }
90 
91  virtual void run(unsigned int iterations);
92 
93  virtual void set_index(unsigned int iindex)
94  {
95  }
96 
97  virtual void set_index(Int_vector iindex)
98  {
99  }
100 
101 
102 protected:
103 
104  virtual void log_sample() { };
105 
106  virtual void compute_energy_gradient();
107 
108  virtual double compute_likelihood() = 0;
109 
114 
119  std::vector < boost::function1<void, double> > callbacks;
120 
125  std::vector < boost::function0<double> > parameter_getters;
126 
127 };
128 
129 
130 }
131 
132 #endif
133 
134 
Definition for the Int_matrix class, a thin wrapper on the KJB Int_matrix struct and its related func...
size_type size() const
Alias to get_length(). Required to comply with stl Container concept.
Definition: m_vector.h:510
virtual ~Likelihood_dynamics()
Definition: likelihood_dynamics.h:89
Likelihood_dynamics & operator=(const Likelihood_dynamics &src)
Definition: likelihood_dynamics.cpp:33
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Likelihood_dynamics(double ialpha=0.99, unsigned int ikick=0)
Definition: likelihood_dynamics.h:51
Abstract_dynamics(double ialpha=0.99, unsigned int ikick=0)
Definition: abstract_dynamics.h:48
virtual void log_sample()
Definition: likelihood_dynamics.h:104
virtual void set_index(unsigned int iindex)
Definition: likelihood_dynamics.h:93
std::vector< boost::function1< void, double > > callbacks
We have a callback for each parameter we are sampling over. Each of them returns a void and accepts a...
Definition: likelihood_dynamics.h:119
This class implements vectors, in the linear-algebra sense, restricted to integer-valued elements...
Definition: l_int_vector.h:83
Definition: likelihood_dynamics.h:38
#define KJB_THROW_2(ex, msg)
Definition: l_exception.h:48
virtual void set_index(Int_vector iindex)
Definition: likelihood_dynamics.h:97
Definition: abstract_dynamics.h:36
virtual double compute_likelihood()=0
Object thrown when an argument to a function is not acceptable.
Definition: l_exception.h:377
virtual void compute_energy_gradient()
Definition: likelihood_dynamics.cpp:41
std::vector< boost::function0< double > > parameter_getters
We have a callback for each parameter we are sampling over. Each of them returns a double...
Definition: likelihood_dynamics.h:125
kjb::Vector etas
The size of the step to use when computing the gradient of the energy function, in a two point estima...
Definition: likelihood_dynamics.h:113
virtual void run(unsigned int iterations)
Definition: likelihood_dynamics.cpp:78