SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ProbabilityDistribution.cpp
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2013 Heiko Strathmann
8  */
9 
11 #include <shogun/base/Parameter.h>
12 #include <shogun/lib/SGVector.h>
13 #include <shogun/lib/SGMatrix.h>
14 
15 using namespace shogun;
16 
18 {
19  init();
20 }
21 
23  CSGObject()
24 {
25  init();
26 
27  REQUIRE(dimension>0, "Dimension of Distribution must be positive\n",
28  dimension);
29 
30  m_dimension=dimension;
31 }
32 
33 
35 {
36 
37 }
38 
40  SGMatrix<float64_t> pre_samples) const
41 {
42  SG_ERROR("Not implemented in sub-class\n");
43  return SGMatrix<float64_t>();
44 }
45 
47 {
50  memcpy(result.vector, s.matrix, m_dimension*sizeof(float64_t));
51  return result;
52 }
53 
55  SGMatrix<float64_t> samples) const
56 {
57  SG_ERROR("Not implemented in sub-class\n");
58  return SGVector<float64_t>();
59 }
60 
62 {
63  REQUIRE(sample_vec.vlen==m_dimension, "Sample dimension (%d) does not "
64  "match dimension of distribution (%d)\n", sample_vec.vlen,
65  m_dimension);
66 
68  memcpy(s.matrix, sample_vec.vector, m_dimension*sizeof(float64_t));
69  return log_pdf_multiple(s)[0];
70 }
71 
72 void CProbabilityDistribution::init()
73 {
74  m_dimension=0;
75 
76  SG_ADD(&m_dimension, "dimension", "Dimension of distribution.",
78 }
#define SG_ERROR(...)
Definition: SGIO.h:129
#define REQUIRE(x,...)
Definition: SGIO.h:206
virtual float64_t log_pdf(SGVector< float64_t > sample_vec) const
index_t vlen
Definition: SGVector.h:494
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:115
double float64_t
Definition: common.h:50
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
virtual SGVector< float64_t > log_pdf_multiple(SGMatrix< float64_t > samples) const
#define SG_ADD(...)
Definition: SGObject.h:84
virtual SGVector< float64_t > sample() const

SHOGUN Machine Learning Toolbox - Documentation