STK++ 0.9.13
STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ > Class Template Reference

A DiagGaussian_muj_sj model is a statistical model of the form: following form. More...

#include <STK_ModelDiagGaussian_muj_sj.h>

Inheritance diagram for STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >:
Inheritance graph

Public Types

typedef DataBridge< Data_Data
 Type of the container storing the data.
 
typedef hidden::Traits< Data_ >::Row RowVector
 
typedef WColVector_ WColVector
 Type of the array storing the weights of the data.
 
typedef hidden::Traits< Data_ >::Type Type
 Type of the data in the container.
 
typedef DiagGaussian_muj_sjParameters Parameters
 Type of the row vector of the container.
 
typedef IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > > Base
 Base class.
 
- Public Types inherited from STK::IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >
typedef hidden::StatModelTraits< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >::Data Data
 Type of the container with the data.
 
typedef hidden::StatModelTraits< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >::Type Type
 Type of the data in the container.
 
typedef hidden::StatModelTraits< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >::WColVector WColVector
 Type of the vector with the weights.
 
typedef hidden::StatModelTraits< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >::Parameters Parameters
 Type of the parameters of the Model.
 

Public Member Functions

 ModelDiagGaussian_muj_sj ()
 default constructor.
 
 ModelDiagGaussian_muj_sj (Data const &data)
 Constructor with data set.
 
 ModelDiagGaussian_muj_sj (Data const *p_data)
 Constructor with a ptr on the data set.
 
 ModelDiagGaussian_muj_sj (ModelDiagGaussian_muj_sj const &model)
 Copy constructor.
 
 ~ModelDiagGaussian_muj_sj ()
 destructor
 
CPointX constmean () const
 
CPointX constsigma () const
 vector of the mean log of the observations
 
int computeNbFreeParameters () const
 compute the number of free parameters
 
Real computeLnLikelihood (RowVector const &rowData) const
 compute the log Likelihood of an observation.
 
void computeParameters ()
 compute the parameters
 
void computeParameters (WColVector const &weights)
 compute the weighted parameters
 
void writeParametersImpl (ostream &os) const
 Write the parameters on the output stream os.
 
- Public Member Functions inherited from STK::IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >
Data const *const p_data () const
 
Parameters constparam () const
 
String consterror () const
 
void setData (Data const *p_data)
 Set the data set.
 
bool run ()
 Estimate the parameters of the model and update the model.
 
bool run (WColVector const &weights)
 compute the weighted empirical probability of success based on the observed variables.
 
void writeParameters (ostream &os)
 
void writeParametersImpl (ostream &os)
 default implementation of the writeParameters method.
 
- Public Member Functions inherited from STK::IStatModelBase
int nbSample () const
 
Real lnNbSample () const
 
int nbVariable () const
 
Real lnLikelihood () const
 
Real likelihood () const
 
int nbFreeParameter () const
 
Real computeBIC () const
 
Real computeAIC () const
 
Real computeML () 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

- Protected Member Functions inherited from STK::IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >
 IMultiStatModel ()
 default constructor.
 
 IMultiStatModel (Data const &data)
 Constructor with data set.
 
 IMultiStatModel (Data const *p_data)
 Constructor with a ptr on the data set.
 
 IMultiStatModel (IMultiStatModel const &model)
 Copy constructor.
 
 ~IMultiStatModel ()
 destructor
 
Parametersparam ()
 
Real computeLnLikelihood () const
 compute the log Likelihood of the statistical model.
 
void update ()
 update the model if a new data set is set
 
- Protected Member Functions inherited from STK::IStatModelBase
 IStatModelBase ()
 Default constructor.
 
 IStatModelBase (int nbSample)
 Constructor with specified dimension.
 
 IStatModelBase (int nbSample, int nbVariable)
 Constructor with specified dimension.
 
 IStatModelBase (IStatModelBase const &model)
 Copy constructor.
 
 ~IStatModelBase ()
 destructor
 
void setNbFreeParameter (int const &nbFreeParameter)
 set the number of free parameters of the model
 
void setNbSample (int const &nbSample)
 set the number of samples of the model
 
void setNbVariable (int const &nbVariable)
 set the number of variables of the model
 
void setLnLikelihood (Real const &lnLikelihood)
 set the log-likelihood of the model
 
void initialize (int nbSample, int nbVariable)
 set the dimensions of the parameters of the model
 
- Protected Member Functions inherited from STK::IRecursiveTemplate< Derived >
 IRecursiveTemplate ()
 constructor.
 
 ~IRecursiveTemplate ()
 destructor.
 
- Protected Attributes inherited from STK::IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >
Data constp_data_
 Pointer on the parameters of the model.
 
Parameters param_
 Pointer on the parameters of the model.
 
String msg_error_
 String with the last error message.
 

Detailed Description

template<class Data_, class WColVector_>
class STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >

A DiagGaussian_muj_sj model is a statistical model of the form: following form.

\[
    f(\mathbf{x}_i|\theta) =
    \prod_{j=1}^p
    \frac{1}{\sigma_j\sqrt{2\pi}}
           \exp\left(-\frac{\left(x_i-\mu_j\right)^2}{2\sigma_j^2} \right)
   \quad j=1,\ldots,p, \quad i=1,\ldots,n.
\]

Definition at line 132 of file STK_ModelDiagGaussian_muj_sj.h.

Member Typedef Documentation

◆ Base

◆ Data

Type of the container storing the data.

Definition at line 136 of file STK_ModelDiagGaussian_muj_sj.h.

◆ Parameters

Type of the row vector of the container.

Type of the parameters of the ModelDiagGaussian_muj_sj

Definition at line 144 of file STK_ModelDiagGaussian_muj_sj.h.

◆ RowVector

◆ Type

Type of the data in the container.

Definition at line 141 of file STK_ModelDiagGaussian_muj_sj.h.

◆ WColVector

Type of the array storing the weights of the data.

Definition at line 139 of file STK_ModelDiagGaussian_muj_sj.h.

Constructor & Destructor Documentation

◆ ModelDiagGaussian_muj_sj() [1/4]

template<class Data_ , class WColVector_ >
STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::ModelDiagGaussian_muj_sj ( )
inline

default constructor.

Definition at line 151 of file STK_ModelDiagGaussian_muj_sj.h.

151: Base() {}
IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > > Base
Base class.

◆ ModelDiagGaussian_muj_sj() [2/4]

template<class Data_ , class WColVector_ >
STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::ModelDiagGaussian_muj_sj ( Data const data)
inline

Constructor with data set.

Definition at line 153 of file STK_ModelDiagGaussian_muj_sj.h.

153: Base(data) {}

◆ ModelDiagGaussian_muj_sj() [3/4]

template<class Data_ , class WColVector_ >
STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::ModelDiagGaussian_muj_sj ( Data const p_data)
inline

Constructor with a ptr on the data set.

Definition at line 155 of file STK_ModelDiagGaussian_muj_sj.h.

◆ ModelDiagGaussian_muj_sj() [4/4]

template<class Data_ , class WColVector_ >
STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::ModelDiagGaussian_muj_sj ( ModelDiagGaussian_muj_sj< Data_, WColVector_ > const model)
inline

Copy constructor.

Definition at line 157 of file STK_ModelDiagGaussian_muj_sj.h.

157: Base(model) {}

◆ ~ModelDiagGaussian_muj_sj()

destructor

Definition at line 159 of file STK_ModelDiagGaussian_muj_sj.h.

159{}

Member Function Documentation

◆ computeLnLikelihood()

template<class Data_ , class WColVector_ >
Real STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::computeLnLikelihood ( RowVector const rowData) const

compute the log Likelihood of an observation.

Definition at line 180 of file STK_ModelDiagGaussian_muj_sj.h.

181{
182 Real sum =0.;
183 for (Integer j= rowData.begin(); j < rowData.end(); ++j)
184 { sum += Law::Normal::lpdf(rowData[j], param().mu(j), param().sigma(j));}
185 return sum;
186}
virtual Real lpdf(Real const &x) const
CPointX const & sigma() const
vector of the mean log of the observations
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.
int Integer
STK fundamental type of integer values.

References STK::Law::Normal::lpdf(), and STK::sum().

◆ computeNbFreeParameters()

template<class Data_ , class WColVector_ >
int STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::computeNbFreeParameters ( ) const
inline

compute the number of free parameters

Definition at line 167 of file STK_ModelDiagGaussian_muj_sj.h.

167{ return 2*p_data()->dataij().sizeCols();}

References STK::IMultiStatModel< ModelDiagGaussian_muj_sj< Data_, WColVector_ > >::p_data().

◆ computeParameters() [1/2]

compute the parameters

Definition at line 190 of file STK_ModelDiagGaussian_muj_sj.h.

191{
192 for (int j=p_data()->dataij().beginCols(); j < p_data()->dataij().endCols(); ++j)
193 {
194 param().mu_[j] = p_data()->dataij().col(j).meanSafe();
195 param().sigma_[j] = std::sqrt(p_data()->dataij().col(j).varianceSafe(param().mu(j)));
196 }
197}
hidden::FunctorTraits< Derived, VarianceSafeOp >::Row varianceSafe(Derived const &A, bool unbiased=false)
Compute safely the variance(s) value(s) of A.

◆ computeParameters() [2/2]

template<class Data_ , class WColVector_ >
void STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::computeParameters ( WColVector const weights)

compute the weighted parameters

Definition at line 200 of file STK_ModelDiagGaussian_muj_sj.h.

201{
202 for (int j=p_data()->dataij().beginCols(); j < p_data()->dataij().endCols(); ++j)
203 {
204 param().mu_[j] = p_data()->dataij().col(j).wmeanSafe(weights);
205 param().sigma_[j] = std::sqrt(p_data()->dataij().col(j).wvarianceSafe(param().mu(j), weights));
206 }
207}

◆ mean()

◆ sigma()

◆ writeParametersImpl()

template<class Data_ , class WColVector_ >
void STK::ModelDiagGaussian_muj_sj< Data_, WColVector_ >::writeParametersImpl ( ostream os) const

Write the parameters on the output stream os.

Definition at line 211 of file STK_ModelDiagGaussian_muj_sj.h.

212{
213 os << _T("mean = ") << mean();
214 os << _T("sigma = ")<< sigma();
215}
#define _T(x)
Let x unmodified.

References _T, and STK::mean().


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