SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
LikelihoodModel.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 Roman Votyakov
8  * Written (W) 2013 Heiko Strathmann
9  * Copyright (C) 2012 Jacob Walker
10  * Copyright (C) 2013 Roman Votyakov
11  */
12 
14 
15 using namespace shogun;
16 
18 {
19 }
20 
22 {
23 }
24 
27 {
28  return get_log_zeroth_moments(mu, s2, lab);
29 }
30 
32  const CLabels* lab, SGMatrix<float64_t> F) const
33 {
34  REQUIRE(lab, "Given labels are NULL!\n");
35  REQUIRE(lab->get_num_labels()==F.num_rows, "Number of labels (%d) does "
36  "not match dimension of functions (%d)\n",
37  lab->get_num_labels(),F.num_rows);
38  REQUIRE(F.num_cols>0, "Number of passed functions (%d) must be positive\n",
39  F.num_cols);
40 
41  SGVector<float64_t> result(F.num_cols);
42  for (index_t i=0; i<F.num_cols; ++i)
43  {
44  /* extract current sample from matrix, assume col-major, dont copy */
45  SGVector<float64_t> f(&F.matrix[i*F.num_rows], F.num_rows, false);
47  }
48 
49  return result;
50 }
51 
53  SGVector<float64_t> s2, const CLabels* lab) const
54 {
55  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
56  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
57  "Length of the vector of means (%d), length of the vector of "
58  "variances (%d) and number of labels (%d) should be the same\n",
59  mu.vlen, s2.vlen, lab->get_num_labels())
60 
61  SGVector<float64_t> result(mu.vlen);
62 
63  for (index_t i=0; i<mu.vlen; i++)
64  result[i]=get_first_moment(mu, s2, lab, i);
65 
66  return result;
67 }
68 
70  SGVector<float64_t> s2, const CLabels* lab) const
71 {
72  REQUIRE(lab, "Labels are required (lab should not be NULL)\n")
73  REQUIRE((mu.vlen==s2.vlen) && (mu.vlen==lab->get_num_labels()),
74  "Length of the vector of means (%d), length of the vector of "
75  "variances (%d) and number of labels (%d) should be the same\n",
76  mu.vlen, s2.vlen, lab->get_num_labels())
77 
78  SGVector<float64_t> result(mu.vlen);
79 
80  for (index_t i=0; i<mu.vlen; i++)
81  result[i]=get_second_moment(mu, s2, lab, i);
82 
83  return result;
84 }

SHOGUN Machine Learning Toolbox - Documentation