STK++ 0.9.13
STK::Poisson_lk< Array > Class Template Reference

The Poisson mixture model Poisson_lk has a probability function of the form. More...

#include <STK_Poisson_lk.h>

Inheritance diagram for STK::Poisson_lk< Array >:
Inheritance graph

Public Types

typedef PoissonBase< Poisson_lk< Array > > Base
 
- Public Types inherited from STK::PoissonBase< Poisson_lk< Array > >
typedef IMixtureDensity< Poisson_lk< Array > > Base
 
- Public Types inherited from STK::IMixtureDensity< Derived >
typedef hidden::MixtureTraits< Derived >::Array Array
 
typedef hidden::MixtureTraits< Derived >::Parameters Parameters
 
typedef hidden::Traits< Array >::Type Type
 

Public Member Functions

 Poisson_lk (int nbCluster)
 default constructor
 
 Poisson_lk (Poisson_lk const &model)
 copy constructor
 
 ~Poisson_lk ()
 destructor
 
Real lambda (int k, int j) const
 
void randomInit (CArrayXX const *const &p_tik, CPointX const *const &p_tk)
 Initialize randomly the parameters of the Poisson mixture.
 
bool run (CArrayXX const *const &p_tik, CPointX const *const &p_tk)
 Compute the weighted probabilities.
 
int computeNbFreeParameters () const
 
- Public Member Functions inherited from STK::PoissonBase< Poisson_lk< Array > >
Real lambda (int k, int j) const
 
void initializeModelImpl ()
 Initialize the parameters of the model.
 
Real lnComponentProbability (int i, int k) const
 
int impute (int i, int j, Weights const &pk) const
 
Real impute (int i, int j, CArrayXX const *p_tik) const
 
int rand (int i, int j, int k) const
 
void getParameters (Array &params) const
 This function is used in order to get the current values of the lambdas.
 
void writeParameters (CArrayXX const *p_tik, ostream &os) const
 This function can be used to write summary of parameters to the output stream.
 
Array const *constp_data () const
 
int nbCluster () const
 
- Public Member Functions inherited from STK::IMixtureDensity< Derived >
 ~IMixtureDensity ()
 destructor
 
int nbCluster () const
 
int nbSample () const
 
Real lnNbSample () const
 
Array const *constp_data () const
 
Parameters constparam () const
 
void setData (Array const &data)
 Set the data set.
 
void setData (Array const &data, int nbRow, int nbCol, bool byRow=true)
 Set the data set and give dimensions.
 
bool initializeStep ()
 This function will be called at the beginning of the estimation process once the model is created and data is set.
 
void setParametersStep ()
 set the parameters obtained with the intermediate results and release the intermediate results.
 
void finalizeStep ()
 This function will be called once the model is estimated.
 
template<class Weights >
Type sample (int i, int j, Weights const &tk) const
 
- Public Member Functions inherited from STK::IRecursiveTemplate< Derived >
Derived & asDerived ()
 static cast : return a reference of this with a cast to the derived class.
 
Derived constasDerived () const
 static cast : return a const reference of this with a cast to the derived class.
 
Derived * asPtrDerived ()
 static cast : return a ptr on a Derived of this with a cast to the derived class.
 
Derived constasPtrDerived () const
 static cast : return a ptr on a constant Derived of this with a cast to the derived class.
 
Derived * clone () const
 create a leaf using the copy constructor of the Derived class.
 
Derived * clone (bool isRef) const
 create a leaf using the copy constructor of the Derived class and a flag determining if the clone is a reference or not.
 

Additional Inherited Members

- Public Attributes inherited from STK::PoissonBase< Poisson_lk< Array > >
Parameters param_
 parameters of the derived mixture model.
 
- Protected Member Functions inherited from STK::PoissonBase< Poisson_lk< Array > >
 PoissonBase (int nbCluster)
 default constructor
 
 PoissonBase (PoissonBase const &model)
 copy constructor
 
 ~PoissonBase ()
 destructor
 
- Protected Member Functions inherited from STK::IMixtureDensity< Derived >
 IMixtureDensity (int nbCluster)
 Default constructor.
 
 IMixtureDensity (IMixtureDensity const &model)
 copy constructor.
 
void initializeModel ()
 Initialize the model before its first use.
 
bool initializeStepImpl ()
 default implementation of initializeStepImpl (do nothing and return true)
 
void finalizeStepImpl ()
 default implementation of finalizeStepImpl (do nothing)
 
void setNbSample (int nbSample)
 Set the number of sample of the model (needed by kernel models)
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 
- Protected Attributes inherited from STK::IMixtureDensity< Derived >
Parameters param_
 parameters of the derived mixture model.
 

Detailed Description

template<class Array>
class STK::Poisson_lk< Array >

The Poisson mixture model Poisson_lk has a probability function of the form.

\[
   P(\mathbf{x}=(n_1,\ldots,n_d)|\theta)
    = \sum_{k=1}^K p_k \prod_{j=1}^d e^{-\lambda_{k}} \frac{\lambda_{k}^{n_j}}{n_j!}.
\]

Definition at line 69 of file STK_Poisson_lk.h.

Member Typedef Documentation

◆ Base

Definition at line 72 of file STK_Poisson_lk.h.

Constructor & Destructor Documentation

◆ Poisson_lk() [1/2]

template<class Array >
STK::Poisson_lk< Array >::Poisson_lk ( int  nbCluster)
inline

default constructor

Parameters
nbClusternumber of cluster in the model

Definition at line 80 of file STK_Poisson_lk.h.

80: Base(nbCluster) {}
PoissonBase< Poisson_lk< Array > > Base

◆ Poisson_lk() [2/2]

template<class Array >
STK::Poisson_lk< Array >::Poisson_lk ( Poisson_lk< Array > const model)
inline

copy constructor

Parameters
modelThe model to copy

Definition at line 84 of file STK_Poisson_lk.h.

84: Base(model) {}

◆ ~Poisson_lk()

template<class Array >
STK::Poisson_lk< Array >::~Poisson_lk ( )
inline

destructor

Definition at line 86 of file STK_Poisson_lk.h.

86{}

Member Function Documentation

◆ computeNbFreeParameters()

template<class Array >
int STK::Poisson_lk< Array >::computeNbFreeParameters ( ) const
inline
Returns
the number of free parameters of the model

Definition at line 94 of file STK_Poisson_lk.h.

94{ return this->nbCluster();}

References STK::PoissonBase< Poisson_lk< Array > >::nbCluster().

◆ lambda()

template<class Array >
Real STK::Poisson_lk< Array >::lambda ( int  k,
int  j 
) const
inline
Returns
the value of lambda of the kth cluster and jth variable

Definition at line 88 of file STK_Poisson_lk.h.

88{ return param_.lambda_[k];}
Parameters param_
parameters of the derived mixture model.

References STK::PoissonBase< Poisson_lk< Array > >::param_.

◆ randomInit()

template<class Array >
void STK::Poisson_lk< Array >::randomInit ( CArrayXX const *const p_tik,
CPointX const *const p_tk 
)

Initialize randomly the parameters of the Poisson mixture.

Definition at line 99 of file STK_Poisson_lk.h.

100{
101 Real m = p_data()->template cast<Real>().mean();
102 for (int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
103 { param_.lambda_[k] = Law::Exponential::rand(m);}
104}
virtual Real rand() const
Generate a pseudo Exponential random variate.
double Real
STK fundamental type of Real values.

References STK::Law::Exponential::rand().

◆ run()

template<class Array >
bool STK::Poisson_lk< Array >::run ( CArrayXX const *const p_tik,
CPointX const *const p_tk 
)

Compute the weighted probabilities.

Definition at line 109 of file STK_Poisson_lk.h.

110{
111 for (int k= p_tik->beginCols(); k < p_tik->endCols(); ++k)
112 {
113 param_.lambda_[k]= 0.;
114 for (int j=p_data()->beginCols(); j< p_data()->endCols(); ++j)
115 {
116 for (int i=p_tik->beginRows(); i < p_tik->endRows(); ++i)
117 { param_.lambda_[k] += p_data()->elt(i,j) * p_tik->elt(i,k);}
118 }
119 param_.lambda_[k] /= p_data()->sizeCols()*p_tk->elt(k);
120 }
121 return true;
122}

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