KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
bbb_likelihood.h
Go to the documentation of this file.
1 /* =========================================================================== *
2  |
3  | Copyright (c) 1994-2011 by Kobus Barnard (author)
4  |
5  | Personal and educational use of this code is granted, provided that this
6  | header is kept intact, and that the authorship is not misrepresented, that
7  | its use is acknowledged in publications, and relevant papers are cited.
8  |
9  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10  |
11  | Please note that the code in this file has not necessarily been adequately
12  | tested. Naturally, there is no guarantee of performance, support, or fitness
13  | for any particular task. Nonetheless, I am interested in hearing about
14  | problems that you encounter.
15  |
16  | Author: Ernesto Brau
17  * =========================================================================== */
18 
19 /* $Id$ */
20 
21 #ifndef B3_LIKELIHOOD_H
22 #define B3_LIKELIHOOD_H
23 
24 #include <bbb_cpp/bbb_data.h>
27 #include <l_cpp/l_exception.h>
28 #include <gp_cpp/gp_base.h>
29 #include <gp_cpp/gp_predictive.h>
30 #include <gp_cpp/gp_covariance.h>
31 #include <gp_cpp/gp_mean.h>
32 #include <m_cpp/m_vector.h>
33 
34 namespace kjb {
35 namespace bbb {
36 
38 {
39 public:
40  typedef gp::Predictive_nl<gp::Manual, gp::Sqex> Predictive;
41 
42 public:
45  data_p(0),
46  pred_(make_default_pred()),
47  library_(library) {}
48 
51  data_p(&data),
52  pred_(make_default_pred()),
53  library_(library) {}
54 
56  double operator()(const Description& desc) const;
57 
59  void set_data(const Data& data) { data_p = &data; }
60 
62  const Data& data() const
63  {
64  IFT(data_p, Runtime_error, "Likelihood data has not been set.");
65  return *data_p;
66  }
67 
69  const Predictive& predictive() const { return pred_; }
70 
72  const Activity_library& library() const { return library_; }
73 
74 private:
75  static Predictive make_default_pred()
76  {
77  using namespace gp;
78 
79  Inputs x(1);
80  Vector f(1);
81  return make_predictive_nl(Manual(x, f), Sqex(1, 1), x, f, x);
82  }
83 
84  const Data* data_p;
85  Predictive pred_;
86  const Activity_library& library_;
87 };
88 
90 Data sample(const Likelihood& likelihood, const Description& desc);
91 
92 }} // namespace kjb::bbb
93 
94 #endif /*B3_LIKELIHOOD_H */
95 
Activity_sequence sample(const As_prior &prior)
Sample an activity sequence from the given prior.
Definition: bbb_activity_sequence_prior.cpp:90
Likelihood(const Activity_library &library)
Construct a likelihood with no data.
Definition: bbb_likelihood.h:44
const Predictive & predictive() const
Get the GP predictive used for this likelihood.
Definition: bbb_likelihood.h:69
Definition: bbb_likelihood.h:37
This class implements vectors, in the linear-algebra sense, with real-valued elements.
Definition: m_vector.h:87
Definition: bbb_description.h:62
double operator()(const Description &desc) const
Compute the likelihood of a description.
Definition: bbb_likelihood.cpp:43
#define IFT(a, ex, msg)
Definition: l_exception.h:101
x
Definition: APPgetLargeConnectedEdges.m:100
const Activity_library & library() const
Get activity library.
Definition: bbb_likelihood.h:72
const Data & data() const
Get the data for this likelihood.
Definition: bbb_likelihood.h:62
Definition: bbb_data.h:37
gp::Predictive_nl< gp::Manual, gp::Sqex > Predictive
Definition: bbb_likelihood.h:40
Support for error handling exception classes in libKJB.
void set_data(const Data &data)
Set the data for this likelihood.
Definition: bbb_likelihood.h:59
Definition: bbb_activity_library.h:38
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...
Likelihood(const Data &data, const Activity_library &library)
Construct a likelihood with the given data.
Definition: bbb_likelihood.h:50
Object thrown when computation fails somehow during execution.
Definition: l_exception.h:321