SHOGUN  3.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Distribution.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) 1999-2009 Soeren Sonnenburg
8  * Written (W) 2014 Parijat Mazumdar
9  * Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
10  */
11 
14 
15 using namespace shogun;
16 
18 : CSGObject(), features(NULL), pseudo_count(1e-10)
19 {
20 }
21 
22 
24 {
26 }
27 
29 {
31 
32  float64_t sum=0;
33  for (int32_t i=0; i<features->get_num_vectors(); i++)
35 
36  return sum/features->get_num_vectors();
37 }
38 
40 {
42 
43  int32_t num=features->get_num_vectors();
44  float64_t* vec=SG_MALLOC(float64_t, num);
45 
46  for (int32_t i=0; i<num; i++)
48 
49  return SGVector<float64_t>(vec,num);
50 }
51 
53 {
54  int32_t total_num=get_num_model_parameters();
55  int32_t num=0;
56 
57  for (int32_t i=0; i<total_num; i++)
58  {
60  num++;
61  }
62  return num;
63 }
64 
66 {
68  int32_t num=features->get_num_vectors();
69  ASSERT(num>0);
70 
72  for (int32_t i=0; i<num; i++)
73  result[i]=get_likelihood_example(i);
74 
75  return result;
76 }
77 
79 {
80  SG_WARNING("Not implemented in this class. This class cannot be used for Mixture models.\n")
82  return -1;
83 }
84 
86 {
87  if (!object)
88  return NULL;
89 
90  CDistribution* casted=dynamic_cast<CDistribution*>(object);
91  if (!casted)
92  return NULL;
93 
94  return casted;
95 }

SHOGUN Machine Learning Toolbox - Documentation