SHOGUN
v2.0.0
Main Page
Related Pages
Modules
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
src
shogun
distributions
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
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
9
*/
10
11
#include <
shogun/distributions/Distribution.h
>
12
#include <
shogun/mathematics/Math.h
>
13
14
using namespace
shogun;
15
16
CDistribution::CDistribution
()
17
:
CSGObject
(), features(NULL), pseudo_count(1e-10)
18
{
19
}
20
21
22
CDistribution::~CDistribution
()
23
{
24
}
25
26
float64_t
CDistribution::get_log_likelihood_sample
()
27
{
28
ASSERT
(
features
);
29
30
float64_t
sum=0;
31
for
(int32_t i=0; i<
features
->
get_num_vectors
(); i++)
32
sum+=
get_log_likelihood_example
(i);
33
34
return
sum/
features
->
get_num_vectors
();
35
}
36
37
SGVector<float64_t>
CDistribution::get_log_likelihood
()
38
{
39
ASSERT
(
features
);
40
41
int32_t num=
features
->
get_num_vectors
();
42
float64_t
* vec=
SG_MALLOC
(
float64_t
, num);
43
44
for
(int32_t i=0; i<num; i++)
45
vec[i]=
get_log_likelihood_example
(i);
46
47
return
SGVector<float64_t>
(vec,num);
48
}
49
50
int32_t
CDistribution::get_num_relevant_model_parameters
()
51
{
52
int32_t total_num=
get_num_model_parameters
();
53
int32_t num=0;
54
55
for
(int32_t i=0; i<total_num; i++)
56
{
57
if
(
get_log_model_parameter
(i)>
CMath::ALMOST_NEG_INFTY
)
58
num++;
59
}
60
return
num;
61
}
SHOGUN
Machine Learning Toolbox - Documentation