SHOGUN
v1.1.0
Main Page
Related Pages
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
shogun
distributions
Gaussian.h
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) 2011 Alesis Novik
8
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
9
*/
10
11
#ifndef _GAUSSIAN_H__
12
#define _GAUSSIAN_H__
13
14
#include <
shogun/lib/config.h
>
15
16
#ifdef HAVE_LAPACK
17
18
#include <
shogun/distributions/Distribution.h
>
19
#include <
shogun/features/DotFeatures.h
>
20
#include <
shogun/lib/common.h
>
21
#include <
shogun/mathematics/lapack.h
>
22
#include <
shogun/mathematics/Math.h
>
23
24
namespace
shogun
25
{
26
class
CDotFeatures;
27
29
enum
ECovType
30
{
32
FULL
,
34
DIAG
,
36
SPHERICAL
37
};
38
46
class
CGaussian
:
public
CDistribution
47
{
48
public
:
50
CGaussian
();
57
CGaussian
(
SGVector<float64_t>
mean,
SGMatrix<float64_t>
cov,
ECovType
cov_type=
FULL
);
58
virtual
~CGaussian
();
59
61
void
init
();
62
69
virtual
bool
train
(
CFeatures
* data=NULL);
70
75
virtual
int32_t
get_num_model_parameters
();
76
82
virtual
float64_t
get_log_model_parameter
(int32_t num_param);
83
90
virtual
float64_t
get_log_derivative
(
91
int32_t num_param, int32_t num_example);
92
100
virtual
float64_t
get_log_likelihood_example
(int32_t num_example);
101
107
virtual
inline
float64_t
compute_PDF
(
SGVector<float64_t>
point)
108
{
109
return
CMath::exp
(
compute_log_PDF
(point));
110
}
111
117
virtual
float64_t
compute_log_PDF
(
SGVector<float64_t>
point);
118
123
virtual
inline
SGVector<float64_t>
get_mean
()
124
{
125
return
m_mean
;
126
}
127
132
virtual
inline
void
set_mean
(
SGVector<float64_t>
mean)
133
{
134
m_mean
.
destroy_vector
();
135
if
(mean.
vlen
==1)
136
m_cov_type
=
SPHERICAL
;
137
138
m_mean
=mean;
139
}
140
145
virtual
SGMatrix<float64_t>
get_cov
();
146
153
virtual
inline
void
set_cov
(
SGMatrix<float64_t>
cov)
154
{
155
ASSERT
(cov.
num_rows
==cov.
num_cols
);
156
ASSERT
(cov.
num_rows
==
m_mean
.
vlen
);
157
decompose_cov(cov);
158
init
();
159
if
(cov.
do_free
)
160
cov.
free_matrix
();
161
}
162
167
inline
ECovType
get_cov_type
()
168
{
169
return
m_cov_type
;
170
}
171
178
inline
void
set_cov_type
(
ECovType
cov_type)
179
{
180
m_cov_type
= cov_type;
181
}
182
187
inline
SGVector<float64_t>
get_d
()
188
{
189
return
m_d
;
190
}
191
196
inline
void
set_d
(
SGVector<float64_t>
d)
197
{
198
m_d
.
destroy_vector
();
199
m_d
= d;
200
init
();
201
}
202
207
inline
SGMatrix<float64_t>
get_u
()
208
{
209
return
m_u
;
210
}
211
216
inline
void
set_u
(
SGMatrix<float64_t>
u)
217
{
218
m_u
.
destroy_matrix
();
219
m_u
= u;
220
}
221
226
SGVector<float64_t>
sample
();
227
229
inline
virtual
const
char
*
get_name
()
const
{
return
"Gaussian"
; }
230
231
private
:
233
void
register_params();
234
239
void
decompose_cov(
SGMatrix<float64_t>
cov);
240
241
protected
:
243
float64_t
m_constant
;
245
SGVector<float64_t>
m_d
;
247
SGMatrix<float64_t>
m_u
;
249
SGVector<float64_t>
m_mean
;
251
ECovType
m_cov_type
;
252
};
253
}
254
#endif //HAVE_LAPACK
255
#endif //_GAUSSIAN_H__
SHOGUN
Machine Learning Toolbox - Documentation