35#ifndef STK_DIAGGAUSSIANBASE_H
36#define STK_DIAGGAUSSIANBASE_H
38#include "../STK_IMixtureDensity.h"
44#include "../DiagGaussianModels/STK_DiagGaussianParameters.h"
52template<
class Derived>
90 template<
class Weights>
101 template<
class Array>
122template<
class Derived>
126 for (
int j=p_data()->beginCols();
j<p_data()->endCols(); ++
j)
138template<
class Derived>
139template<
class Weights>
143 for (
int k= pk.begin(); k < pk.end(); ++k)
148template<
class Derived>
156 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
161 param_.mean_[k] = p_data()->row(
indexes[
i]);
170template<
class Derived>
173 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
175 for (
int j=p_data()->beginCols();
j< p_data()->endCols(); ++
j)
176 { param_.mean_[k][
j] = p_data()->col(
j).wmean(p_tik->
col(k));}
185template<
class Derived>
191 for (
int k= 0; k <
nbClust; ++k)
206template<
class Derived>
209 CPointX m(p_data()->cols()), s(p_data()->cols());
210 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
213 for (
int j= s.begin();
j < s.end(); ++
j)
215 os <<
_T(
"---> Component ") << k <<
_T(
"\n");
216 os <<
_T(
"mean = ") <<
m;
217 os <<
_T(
"sigma = ")<< s;
In this file we define the constant Arrays.
This file define methods for displaying Arrays and Expressions.
In this file we define the Normal probability law class.
#define _T(x)
Let x unmodified.
Base class for the diagonal Gaussian models.
DiagGaussianBase(DiagGaussianBase const &model)
copy constructor
Real const & mean(int k, int j) const
void initializeModelImpl()
Initialize the parameters of the model.
Real impute(int i, int j, Weights const &pk) const
Array const *const & p_data() const
Real lnComponentProbability(int i, int k) const
Real const & sigma(int k, int j) const
IMixtureDensity< Derived > Base
Parameters param_
parameters of the derived mixture model.
~DiagGaussianBase()
destructor
bool updateMean(CArrayXX const *p_tik)
compute the weighted mean of a Gaussian mixture.
Real rand(int i, int j, int k) const
void writeParameters(CArrayXX const *p_tik, ostream &os) const
This function can be used to write summary of parameters to the output stream.
void getParameters(Array ¶ms) const
This function is used in order to get the current values of the means and standard deviations.
void randomMean(CArrayXX const *p_tik)
sample randomly the mean of each component by sampling randomly a row of the data set.
DiagGaussianBase(int nbCluster)
default constructor
hidden::CSlice< Derived, sizeRows_, 1 >::Result col(int j) const
implement the col operator using a reference on the column of the allocator
Base class for all Mixture densities.
Array const *const & p_data() const
Parameters param_
parameters of the derived mixture model.
hidden::MixtureTraits< Derived >::Array Array
virtual Real lpdf(Real const &x) const
Real rand() const
Generate a pseudo Normal random variate.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Index sub-vector region: Specialization when the size is unknown.
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
const int baseIdx
base index of the containers created in STK++.
double Real
STK fundamental type of Real values.
hidden::SliceVisitorSelector< Derived, hidden::MeanVisitor, Arrays::by_col_ >::type_result mean(Derived const &A)
If A is a row-vector or a column-vector then the function will return the usual mean value of the vec...
std::basic_ostream< Char > ostream
ostream for Char
The namespace STK is the main domain space of the Statistical ToolKit project.