SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Public Member Functions | Protected Attributes
CGaussian Class Reference

Detailed Description

Gaussian distribution interface.

Takes as input a mean vector and covariance matrix. Also possible to train from data. Likelihood is computed using the Gaussian PDF $(2\pi)^{-\frac{k}{2}}|\Sigma|^{-\frac{1}{2}}e^{-\frac{1}{2}(x-\mu)'\Sigma^{-1}(x-\mu)}$ The actual computations depend on the type of covariance used.

Definition at line 46 of file Gaussian.h.

Inheritance diagram for CGaussian:
Inheritance graph
[legend]

Public Member Functions

 CGaussian ()
 CGaussian (SGVector< float64_t > mean, SGMatrix< float64_t > cov, ECovType cov_type=FULL)
virtual ~CGaussian ()
void init ()
virtual bool train (CFeatures *data=NULL)
virtual int32_t get_num_model_parameters ()
virtual float64_t get_log_model_parameter (int32_t num_param)
virtual float64_t get_log_derivative (int32_t num_param, int32_t num_example)
virtual float64_t get_log_likelihood_example (int32_t num_example)
virtual float64_t compute_PDF (SGVector< float64_t > point)
virtual float64_t compute_log_PDF (SGVector< float64_t > point)
virtual SGVector< float64_tget_mean ()
virtual void set_mean (SGVector< float64_t > mean)
virtual SGMatrix< float64_tget_cov ()
virtual void set_cov (SGMatrix< float64_t > cov)
ECovType get_cov_type ()
void set_cov_type (ECovType cov_type)
SGVector< float64_tget_d ()
void set_d (SGVector< float64_t > d)
SGMatrix< float64_tget_u ()
void set_u (SGMatrix< float64_t > u)
SGVector< float64_tsample ()
virtual const char * get_name () const
- Public Member Functions inherited from CDistribution
 CDistribution ()
virtual ~CDistribution ()
virtual int32_t get_num_relevant_model_parameters ()
virtual float64_t get_log_likelihood_sample ()
virtual SGVector< float64_tget_log_likelihood ()
virtual float64_t get_model_parameter (int32_t num_param)
virtual float64_t get_derivative (int32_t num_param, int32_t num_example)
virtual float64_t get_likelihood_example (int32_t num_example)
virtual void set_features (CFeatures *f)
virtual CFeaturesget_features ()
virtual void set_pseudo_count (float64_t pseudo)
virtual float64_t get_pseudo_count ()
- Public Member Functions inherited from CSGObject
 CSGObject ()
 CSGObject (const CSGObject &orig)
virtual ~CSGObject ()
virtual bool is_generic (EPrimitiveType *generic) const
template<class T >
void set_generic ()
void unset_generic ()
virtual void print_serializable (const char *prefix="")
virtual bool save_serializable (CSerializableFile *file, const char *prefix="")
virtual bool load_serializable (CSerializableFile *file, const char *prefix="")
void set_global_io (SGIO *io)
SGIOget_global_io ()
void set_global_parallel (Parallel *parallel)
Parallelget_global_parallel ()
void set_global_version (Version *version)
Versionget_global_version ()
SGVector< char * > get_modelsel_names ()
char * get_modsel_param_descr (const char *param_name)
index_t get_modsel_param_index (const char *param_name)

Protected Attributes

float64_t m_constant
SGVector< float64_tm_d
SGMatrix< float64_tm_u
SGVector< float64_tm_mean
ECovType m_cov_type
- Protected Attributes inherited from CDistribution
CFeaturesfeatures
float64_t pseudo_count

Additional Inherited Members

- Public Attributes inherited from CSGObject
SGIOio
Parallelparallel
Versionversion
Parameterm_parameters
Parameterm_model_selection_parameters
- Protected Member Functions inherited from CSGObject
virtual void load_serializable_pre () throw (ShogunException)
virtual void load_serializable_post () throw (ShogunException)
virtual void save_serializable_pre () throw (ShogunException)
virtual void save_serializable_post () throw (ShogunException)

Constructor & Destructor Documentation

CGaussian ( )

default constructor

Definition at line 20 of file Gaussian.cpp.

CGaussian ( SGVector< float64_t mean,
SGMatrix< float64_t cov,
ECovType  cov_type = FULL 
)

constructor

Parameters
meanmean of the Gaussian
covcovariance of the Gaussian
cov_typecovariance type (full, diagonal or shperical)

Definition at line 25 of file Gaussian.cpp.

~CGaussian ( )
virtual

Definition at line 60 of file Gaussian.cpp.

Member Function Documentation

float64_t compute_log_PDF ( SGVector< float64_t point)
virtual

compute log PDF

Parameters
pointpoint for which to compute the log PDF
Returns
computed log PDF

Definition at line 126 of file Gaussian.cpp.

virtual float64_t compute_PDF ( SGVector< float64_t point)
virtual

compute PDF

Parameters
pointpoint for which to compute the PDF
Returns
computed PDF

Definition at line 107 of file Gaussian.h.

SGMatrix< float64_t > get_cov ( )
virtual

get covariance

Parameters
covcovariance, memory needs to be freed by user

Definition at line 165 of file Gaussian.cpp.

ECovType get_cov_type ( )

get covariance type

Returns
covariance type

Definition at line 167 of file Gaussian.h.

SGVector<float64_t> get_d ( )

get diagonal

Returns
diagonal

Definition at line 187 of file Gaussian.h.

float64_t get_log_derivative ( int32_t  num_param,
int32_t  num_example 
)
virtual

get partial derivative of likelihood function (logarithmic)

Parameters
num_paramderivative against which param
num_examplewhich example
Returns
derivative of likelihood (logarithmic)

Implements CDistribution.

Definition at line 111 of file Gaussian.cpp.

float64_t get_log_likelihood_example ( int32_t  num_example)
virtual

compute log likelihood for example

abstract base method

Parameters
num_examplewhich example
Returns
log likelihood for example

Implements CDistribution.

Definition at line 117 of file Gaussian.cpp.

float64_t get_log_model_parameter ( int32_t  num_param)
virtual

get model parameter (logarithmic)

Returns
model parameter (logarithmic) if num_param < m_dim returns an element from the mean, else return an element from the covariance

Implements CDistribution.

Definition at line 105 of file Gaussian.cpp.

virtual SGVector<float64_t> get_mean ( )
virtual

get mean

Returns
mean

Definition at line 123 of file Gaussian.h.

virtual const char* get_name ( ) const
virtual
Returns
object name

Implements CSGObject.

Definition at line 229 of file Gaussian.h.

int32_t get_num_model_parameters ( )
virtual

get number of parameters in model

Returns
number of parameters in model

Implements CDistribution.

Definition at line 91 of file Gaussian.cpp.

SGMatrix<float64_t> get_u ( )

get unitary matrix

Returns
unitary matrix

Definition at line 207 of file Gaussian.h.

void init ( )

Compute the constant part

Reimplemented from CSGObject.

Definition at line 44 of file Gaussian.cpp.

SGVector< float64_t > sample ( )

sample from distribution

Returns
sample

Definition at line 245 of file Gaussian.cpp.

virtual void set_cov ( SGMatrix< float64_t cov)
virtual

set covariance

Doesn't store the covariance, but decomposes, thus the covariance can be freed after exit without harming the object

Parameters
covnew covariance

Definition at line 153 of file Gaussian.h.

void set_cov_type ( ECovType  cov_type)

set covariance type

Will only take effect after covariance is changed

Parameters
cov_typenew covariance type

Definition at line 178 of file Gaussian.h.

void set_d ( SGVector< float64_t d)

set diagonal

Parameters
dnew diagonal

Definition at line 196 of file Gaussian.h.

virtual void set_mean ( SGVector< float64_t mean)
virtual

set mean

Parameters
meannew mean

Definition at line 132 of file Gaussian.h.

void set_u ( SGMatrix< float64_t u)

set unitary matrix

Parameters
unew unitary matrix

Definition at line 216 of file Gaussian.h.

bool train ( CFeatures data = NULL)
virtual

learn distribution

Parameters
datatraining data
Returns
whether training was successful

Implements CDistribution.

Definition at line 67 of file Gaussian.cpp.

Member Data Documentation

float64_t m_constant
protected

constant part

Definition at line 243 of file Gaussian.h.

ECovType m_cov_type
protected

covariance type

Definition at line 251 of file Gaussian.h.

SGVector<float64_t> m_d
protected

diagonal

Definition at line 245 of file Gaussian.h.

SGVector<float64_t> m_mean
protected

mean

Definition at line 249 of file Gaussian.h.

SGMatrix<float64_t> m_u
protected

unitary matrix

Definition at line 247 of file Gaussian.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation