35#ifndef STK_GAMMA_AK_BJK_H
36#define STK_GAMMA_AK_BJK_H
39#include "../GammaModels/STK_GammaBase.h"
43template<
class Array>
class Gamma_ak_bjk;
110 this->moments(p_tik);
111 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
114 for (
int j=p_data()->beginCols();
j < p_data()->endCols(); ++
j)
116 Real mean = meanjk(
j,k), variance = variancejk(
j,k);
122#ifdef STK_MIXTURE_VERY_VERBOSE
123 stk_cout <<
_T(
" Gamma_ak_bjk<Array>::randomInit done\n");
131 if (!this->moments(p_tik)) {
return false;}
133 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
136 Real x0 = (param_.mean_[k].square()/param_.variance_[k]).
mean();
137 Real x1 = param_.shape_[k];
138 if ((
x0 <=0.) || (
isNA(
x0)))
return false;
145#ifdef STK_MIXTURE_DEBUG
146 stk_cout <<
"ML estimation failed in Gamma_ak_bjk::run( CArrayXX const* const& p_tik, CPointX const* const& p_tk) \n";
156 for (
int j=p_data()->beginCols();
j < p_data()->endCols(); ++
j)
157 { param_.scale_[k][
j] = param_.mean_[k][
j]/a; }
In this file we implement the exponential law.
#define stk_cout
Standard stk output stream.
#define _T(x)
Let x unmodified.
Base class for the gamma models.
Array const *const & p_data() const
Parameters param_
parameters of the derived mixture model.
Real meanjk(int j, int k)
get the weighted mean of the jth variable of the kth cluster.
Real variancejk(int j, int k)
get the weighted variance of the jth variable of the kth cluster.
Gamma_ak_bjk is a mixture model of the following form.
int computeNbFreeParameters() const
~Gamma_ak_bjk()
destructor
bool run(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Compute the run( CArrayXX const* const& p_tik, CPointX const* const& p_tk) .
Gamma_ak_bjk(int nbCluster)
default constructor
Gamma_ak_bjk(Gamma_ak_bjk const &model)
copy constructor
GammaBase< Gamma_ak_bjk< Array > > Base
void randomInit(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Initialize randomly the parameters of the Gamma mixture.
virtual Real rand() const
Generate a pseudo Exponential random variate.
The MultidimRegression class allows to regress a multidimensional output variable among a multivariat...
Functor computing the derivative of the lnLikelihood of a gamma_ajk_bjk model.
Real findZero(IFunction< Function > const &f, Real const &x0, Real const &x1, Real tol)
find the zero of a function.
bool isNA(Type const &x)
utility method allowing to know if a value is a NA (Not Available) value
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...
The namespace STK is the main domain space of the Statistical ToolKit project.
Arithmetic properties of STK fundamental types.
ModelParameters< Clust::Gamma_ak_bjk_ > Parameters
Type of the structure storing the parameters of a Gamma_ak_bjk model.
Main class for the mixtures traits policy.