38#include "../STK_IMixtureDensity.h"
52template<
class Derived>
94 template<
class Vector>
115 template<
class Weights>
126 template<
class ArrayParam>
171template<
class Derived>
174#ifdef STK_KERNELS_DEBUG
175 stk_cout <<
_T(
"Entering KmmBase::compute_dik\n");
176 stk_cout <<
_T(
"dik_.cols() =") << dik_.cols() <<
_T(
"\n");
177 stk_cout <<
_T(
"dik_.rows() =") << dik_.rows() <<
_T(
"\n");
180 for (
int k=dik_.beginCols(); k<dik_.endCols(); ++k)
183 for (
int i=
wik.begin();
i <
wik.end(); ++
i)
186 for (
int j=
wik.begin();
j <
wik.end(); ++
j)
187 {
wik[
i] += p_kernel_->comp(
i,
j) * p_tik->elt(
j,k);}
192 for (
int i=
wik.begin();
i<
wik.end(); ++
i)
193 { dik_(
i,k) = p_kernel_->diag(
i) - 2. *
wik[
i] +
dk ;}
195#ifdef STK_KERNELS_DEBUG
196 stk_cout <<
_T(
"KmmBase::compute_dik done\n");
210template<
class Derived>
214 this->setNbSample(p_kernel_->nbSample());
215 dik_.resize(p_kernel_->nbSample(), nbCluster());
217 this->asDerived().initializeModelImpl();
225template<
class Derived>
226template<
class ArrayParam>
229 param.resize(this->nbCluster(), 2);
230 for (
int k= param.beginRows(); k < param.endRows(); ++k)
232 param(k,
baseIdx ) = param_.sigma2(k);
233 param(k,
baseIdx+1) = param_.dim(k);
240template<
class Derived>
243 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
245 os <<
_T(
"---> Component ") << k <<
_T(
"\n");
246 os <<
_T(
"sigma2 = ") << param_.sigma2(k) <<
_T(
"\n");
247 os <<
_T(
"dim = ") << param_.dim(k) <<
_T(
"\n");
In this file we implement the final class CArrayPoint.
In this file we implement the final class CArrayVector.
In this file we implement the final class CArray.
In this file we define the Parameters classes for kernel mixture models.
In this file we define the Interface base class for computing a Kernels.
#define STK_STATIC_ASSERT_ONE_DIMENSION_ONLY(EXPR)
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
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.
Parameters param_
parameters of the derived mixture model.
Array const * p_dataij_
pointer on the data set
Interface class for the kernels classes.
Base class for the Gaussian Kernel Mixture Models.
void getParameters(ArrayParam ¶ms) const
This function is used in order to get the current values of the parameters in an array.
Real impute(int i, int j, Weights const &pk) const
void initializeModelImpl()
default implementation of initializeModelImpl (do nothing)
Kernel::IKernel const *const p_kernel() const
void setData(Array const &data)
Set the data set.
void setDim(Real const &dim)
set the dimensions of the kernel mixture model using an unique value
CArrayXX dik_
Array of the intermediate results dik.
Parameters param_
parameters of the derived mixture model.
KmmBase(KmmBase const &model)
copy constructor
KmmBase(int nbCluster)
default constructor
void compute_dik(CArrayXX const *p_tik, CPointX const *p_tk)
compute the distance of the ith individual to the kth centroid
Kernel::IKernel const * p_kernel_
pointer on the kernel
Real rand(int i, int j, int k) const
IMixtureDensity< Derived > Base
hidden::MixtureTraits< Derived >::Array Array
void initializeModel()
Initialize the model before its first use.
void setKernel(Kernel::IKernel const *p_kernel)
set the dimensions of the kernel mixture model using an unique value.
void writeParameters(CArrayXX const *p_tik, ostream &os) const
This function can be used to write summary of parameters to the output stream.
void setDim(ExprBase< Vector > const &dim)
set the dimension of the kernel mixture model
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
const int baseIdx
base index of the containers created in STK++.
double Real
STK fundamental type of Real values.
std::basic_ostream< Char > ostream
ostream for Char
The namespace STK is the main domain space of the Statistical ToolKit project.
Main class for the mixtures traits policy.