35#ifndef STK_GAMMA_A_BK_H
36#define STK_GAMMA_A_BK_H
39#include "../GammaModels/STK_GammaBase.h"
43template<
class Array>
class Gamma_a_bk;
109 this->moments(p_tik);
111 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
113 Real mean = meank(k), variance = variancek(k);
116 value += p_tk->elt(k) * (
mean*
mean/variance);
119#ifdef STK_MIXTURE_VERY_VERBOSE
120 stk_cout <<
_T(
" Gamma_a_bk<Array>::randomInit( CArrayXX const* const& p_tik, CPointX const* const& p_tk) done\n");
130 if (!moments(p_tik)) {
flag =
false;}
132 Real y =0.0,
x0 = 0.0,
x1 = param_.shape_;
133 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
136 y += p_tk->elt(k) * (param_.meanLog_[k] - std::log(
mean)).
sum();
137 x0 += p_tk->elt(k) * (
mean*
mean/variancek(k));
139 y /= (this->nbSample()*p_data()->sizeCols());
140 x0 /= this->nbSample();
154#ifdef STK_MIXTURE_DEBUG
155 stk_cout <<
"ML estimation failed in Gamma_a_bjk::run( CArrayXX const* const& p_tik, CPointX const* const& p_tk) \n";
167#ifdef STK_MIXTURE_DEBUG
168 stk_cout <<
"ML estimation failed in Gamma_a_bjk::run( CArrayXX const* const& p_tik, CPointX const* const& p_tk) \n";
180 for (
int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
181 { param_.scale_[k] = meank(k)/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.
Real meank(int k)
get the mean of the weighted means of the kth cluster.
Array const *const & p_data() const
Real variancek(int k)
get the mean of the weighted variances of the kth cluster.
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.
bool moments(CArrayXX const *p_tik)
compute the weighted moments of a gamma mixture.
Real variancejk(int j, int k)
get the weighted variance of the jth variable of the kth cluster.
Gamma_a_bk is a mixture model of the following form.
int computeNbFreeParameters() const
void randomInit(CArrayXX const *const &p_tik, CPointX const *const &p_tk)
Initialize randomly the parameters of the Gamma mixture.
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_a_bk(Gamma_a_bk const &model)
copy constructor
GammaBase< Gamma_a_bk< Array > > Base
Gamma_a_bk(int nbCluster)
default constructor
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
Arrays::SumOp< Lhs, Rhs >::result_type sum(Lhs const &lhs, Rhs const &rhs)
convenience function for summing two arrays
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_a_bk_ > Parameters
Type of the structure storing the parameters of a Mixture Gamma_a_bk model.
Main class for the mixtures traits policy.