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 {
25 }
26 
28 {
30 
31  float64_t sum=0;
32  for (int32_t i=0; i<features->get_num_vectors(); i++)
34 
35  return sum/features->get_num_vectors();
36 }
37 
39 {
41 
42  int32_t num=features->get_num_vectors();
43  float64_t* vec=SG_MALLOC(float64_t, num);
44 
45  for (int32_t i=0; i<num; i++)
47 
48  return SGVector<float64_t>(vec,num);
49 }
50 
52 {
53  int32_t total_num=get_num_model_parameters();
54  int32_t num=0;
55 
56  for (int32_t i=0; i<total_num; i++)
57  {
59  num++;
60  }
61  return num;
62 }
63 
65 {
67  int32_t num=features->get_num_vectors();
68  ASSERT(num>0);
69 
71  for (int32_t i=0; i<num; i++)
72  result[i]=get_likelihood_example(i);
73 
74  return result;
75 }
76 
78 {
79  SG_WARNING("Not implemented in this class. This class cannot be used for Mixture models.\n")
81 }
82 
84 {
85  if (!object)
86  return NULL;
87 
88  CDistribution* casted=dynamic_cast<CDistribution*>(object);
89  if (!casted)
90  return NULL;
91 
92  SG_REF(casted);
93  return casted;
94 }
static CDistribution * obtain_from_generic(CSGObject *object)
virtual SGVector< float64_t > get_log_likelihood()
virtual int32_t get_num_vectors() const =0
#define SG_NOTIMPLEMENTED
Definition: SGIO.h:140
virtual int32_t get_num_relevant_model_parameters()
Base class Distribution from which all methods implementing a distribution are derived.
Definition: Distribution.h:44
static const float64_t ALMOST_NEG_INFTY
almost neg (log) infinity
Definition: Math.h:1419
virtual float64_t get_log_model_parameter(int32_t num_param)=0
virtual float64_t get_log_likelihood_sample()
#define ASSERT(x)
Definition: SGIO.h:202
Class SGObject is the base class of all shogun objects.
Definition: SGObject.h:98
double float64_t
Definition: common.h:50
#define SG_REF(x)
Definition: SGRefObject.h:34
virtual float64_t get_likelihood_example(int32_t num_example)
Definition: Distribution.h:145
virtual void update_params_em(SGVector< float64_t > alpha_k)
virtual SGVector< float64_t > get_likelihood_for_all_examples()
#define SG_WARNING(...)
Definition: SGIO.h:129
virtual float64_t get_log_likelihood_example(int32_t num_example)=0
virtual int32_t get_num_model_parameters()=0

SHOGUN Machine Learning Toolbox - Documentation