STK++ 0.9.13
STK::MultiLaw::JointProbability< RowVector, Law > Class Template Reference

joint density class for the multivariate distributions. More...

#include <STK_MultiLaw_IMultiLaw.h>

Inheritance diagram for STK::MultiLaw::JointProbability< RowVector, Law >:
Inheritance graph

Public Types

typedef RowVector::Type Type
 
typedef IMultiLaw< RowVector > Base
 

Public Member Functions

 JointProbability (String const &name)
 Constructor.
 
 JointProbability (String const &name, int nbVar)
 Constructor.
 
virtual ~JointProbability ()
 destructor
 
Array1D< Law > constJointLaw () const
 
Law constlaw (int const &j) const
 
Law & law (int const &j)
 
Law constatLaw (int const &j) const
 
Law & atLaw (int const &j)
 
void resize (int const &nbVar)
 resize the joint probability
 
virtual Real pdf (RowVector const &x) const
 compute the probability distribution function (density) of the multivariate law.
 
virtual Real lpdf (RowVector const &x) const
 compute the log probability distribution function Give the value of the log-pdf at the point x.
 
virtual void rand (RowVector &x) const
 simulate a realization of the joint law and store the result in x.
 
- Public Member Functions inherited from STK::MultiLaw::IMultiLaw< RowVector >
virtual ~IMultiLaw ()
 destructor.
 
- Public Member Functions inherited from STK::Law::ILawBase
String constname () const
 

Protected Attributes

Array1D< Law > jointLaw_
 Array with the marginal laws.
 
- Protected Attributes inherited from STK::Law::ILawBase
String name_
 Name of the Law.
 

Additional Inherited Members

- Protected Member Functions inherited from STK::MultiLaw::IMultiLaw< RowVector >
 IMultiLaw (String const &name)
 Constructor.
 
- Protected Member Functions inherited from STK::Law::ILawBase
 ILawBase (String const &name)
 Constructor.
 
 ~ILawBase ()
 destructor.
 

Detailed Description

template<class RowVector, class Law>
class STK::MultiLaw::JointProbability< RowVector, Law >

joint density class for the multivariate distributions.

Given some sample x in some data space, a JointProbability will model a joint probability law. All the marginal densities/probabilities will belong to the same family.

Template Parameters
RowVectoris the type of container containing a sample x.
LawAny probability law deriving from Law::IUnivLaw.

Definition at line 100 of file STK_MultiLaw_IMultiLaw.h.

Member Typedef Documentation

◆ Base

template<class RowVector , class Law >
typedef IMultiLaw<RowVector> STK::MultiLaw::JointProbability< RowVector, Law >::Base

Definition at line 104 of file STK_MultiLaw_IMultiLaw.h.

◆ Type

template<class RowVector , class Law >
typedef RowVector::Type STK::MultiLaw::JointProbability< RowVector, Law >::Type

Definition at line 103 of file STK_MultiLaw_IMultiLaw.h.

Constructor & Destructor Documentation

◆ JointProbability() [1/2]

template<class RowVector , class Law >
STK::MultiLaw::JointProbability< RowVector, Law >::JointProbability ( String const name)
inline

Constructor.

Parameters
namename of the joint law

Definition at line 108 of file STK_MultiLaw_IMultiLaw.h.

109 : Base(name), jointLaw_() {}
String const & name() const
Array1D< Law > jointLaw_
Array with the marginal laws.

◆ JointProbability() [2/2]

template<class RowVector , class Law >
STK::MultiLaw::JointProbability< RowVector, Law >::JointProbability ( String const name,
int  nbVar 
)
inline

Constructor.

Parameters
namename of the joint law
nbVardimension of the sample

Definition at line 114 of file STK_MultiLaw_IMultiLaw.h.

115 : Base(name), jointLaw_(nbVar) {}

◆ ~JointProbability()

template<class RowVector , class Law >
virtual STK::MultiLaw::JointProbability< RowVector, Law >::~JointProbability ( )
inlinevirtual

destructor

Definition at line 117 of file STK_MultiLaw_IMultiLaw.h.

117{}

Member Function Documentation

◆ atLaw() [1/2]

template<class RowVector , class Law >
Law & STK::MultiLaw::JointProbability< RowVector, Law >::atLaw ( int const j)
inline
Returns
safely the jth marginal law

Definition at line 128 of file STK_MultiLaw_IMultiLaw.h.

128{ return jointLaw_.at(j);}

References STK::ITContainer1D< Derived >::at(), and STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_.

◆ atLaw() [2/2]

template<class RowVector , class Law >
Law const & STK::MultiLaw::JointProbability< RowVector, Law >::atLaw ( int const j) const
inline
Returns
safely the jth marginal law

Definition at line 126 of file STK_MultiLaw_IMultiLaw.h.

126{ return jointLaw_.at(j);}

References STK::ITContainer1D< Derived >::at(), and STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_.

◆ JointLaw()

template<class RowVector , class Law >
Array1D< Law > const & STK::MultiLaw::JointProbability< RowVector, Law >::JointLaw ( ) const
inline
Returns
the array with the marginals laws

Definition at line 119 of file STK_MultiLaw_IMultiLaw.h.

119{ return jointLaw_;}

References STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_.

◆ law() [1/2]

template<class RowVector , class Law >
Law & STK::MultiLaw::JointProbability< RowVector, Law >::law ( int const j)
inline
Returns
the jth marginal law

Definition at line 124 of file STK_MultiLaw_IMultiLaw.h.

124{ return jointLaw_[j];}

References STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_.

◆ law() [2/2]

template<class RowVector , class Law >
Law const & STK::MultiLaw::JointProbability< RowVector, Law >::law ( int const j) const
inline
Returns
the jth marginal law

Definition at line 122 of file STK_MultiLaw_IMultiLaw.h.

122{ return jointLaw_[j];}

References STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_.

◆ lpdf()

template<class RowVector , class Law >
virtual Real STK::MultiLaw::JointProbability< RowVector, Law >::lpdf ( RowVector const x) const
inlinevirtual

compute the log probability distribution function Give the value of the log-pdf at the point x.

Parameters
xthe multivariate value to compute the lpdf.
Returns
the value of the log-pdf

Implements STK::MultiLaw::IMultiLaw< RowVector >.

Definition at line 145 of file STK_MultiLaw_IMultiLaw.h.

146 {
147 if (x.range() != jointLaw_.range())
148 {STKRUNTIME_ERROR_NO_ARG(JointProbability::lpdf(x),dimensions mismatch);}
149 Real sum = 0.;
150 for (int j= x.begin(); j <= x.lastIdx(); ++j)
151 { sum+= Arithmetic<Type>::isNA(x[j]) ? 0. : jointLaw_[j].lpdf(x[j]);}
152 return sum;
153 }
#define STKRUNTIME_ERROR_NO_ARG(Where, Error)
Definition STK_Macros.h:138
RowRange const & range() const
virtual Real lpdf(RowVector const &x) const
compute the log probability distribution function Give the value of the log-pdf at the point x.
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.
static bool isNA(Type const &x)

References STK::Arithmetic< Type >::isNA(), STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_, STK::MultiLaw::JointProbability< RowVector, Law >::lpdf(), STK::IArray1D< Derived >::range(), STKRUNTIME_ERROR_NO_ARG, and STK::sum().

Referenced by STK::MultiLaw::JointProbability< RowVector, Law >::lpdf(), and STK::MultiLaw::JointProbability< RowVector, Law >::pdf().

◆ pdf()

template<class RowVector , class Law >
virtual Real STK::MultiLaw::JointProbability< RowVector, Law >::pdf ( RowVector const x) const
inlinevirtual

compute the probability distribution function (density) of the multivariate law.

Give the value of the pdf at the point x.

Parameters
xthe multivariate value to compute the pdf.
Returns
the value of the pdf

Implements STK::MultiLaw::IMultiLaw< RowVector >.

Definition at line 138 of file STK_MultiLaw_IMultiLaw.h.

139 { return std::exp((double)lpdf(x));}

References STK::MultiLaw::JointProbability< RowVector, Law >::lpdf().

◆ rand()

template<class RowVector , class Law >
virtual void STK::MultiLaw::JointProbability< RowVector, Law >::rand ( RowVector &  x) const
inlinevirtual

simulate a realization of the joint law and store the result in x.

Parameters
[out]xthe simulated value.

Implements STK::MultiLaw::IMultiLaw< RowVector >.

Definition at line 158 of file STK_MultiLaw_IMultiLaw.h.

159 {
160 x.resize(jointLaw_.range());
161 for (int j= x.begin(); j <= x.lastIdx(); ++j)
162 { x[j] = jointLaw_[j].rand();}
163 }

References STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_, and STK::IArray1D< Derived >::range().

◆ resize()

template<class RowVector , class Law >
void STK::MultiLaw::JointProbability< RowVector, Law >::resize ( int const nbVar)
inline

resize the joint probability

Definition at line 130 of file STK_MultiLaw_IMultiLaw.h.

130{ jointLaw_.resize(nbVar);}
Derived & resize(Range const &I=RowRange())

References STK::MultiLaw::JointProbability< RowVector, Law >::jointLaw_, and STK::ITContainer1D< Derived >::resize().

Member Data Documentation

◆ jointLaw_


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