mixpp: bdm Namespace Reference

bdm Namespace Reference

Space of basic BDM structures. More...


Classes

class  str
 Structure of RV, i.e. RVs expanded into a flat list of IDs, used for debugging. More...
class  RV
 Class representing variables, most often random variables. More...
class  log_level_intermediate
class  logger
 Class for storing results (and semi-results) of an experiment. More...
class  log_level_template
 This class stores a details that will be logged to a logger. More...
class  fnc
 Class representing function $f(x)$ of variable $x$ represented by rv. More...
class  pdf
 Conditional probability density, e.g. modeling $ f( x | y) $, where $ x $ is random variable, rv, and $ y $ is conditioning variable, rvc. More...
class  epdf
 Abstract class representing probability density function with numerical statistics, e.g. posterior density. More...
class  pdf_internal
 pdf with internal epdf that is modified by function condition More...
class  datalink
 DataLink is a connection between two data vectors Up and Down. More...
class  datalink_part
class  datalink_buffered
 Datalink that buffers delayed values - do not forget to call step(). More...
class  vec_from_vec
class  vec_from_2vec
class  datalink_2to1_buffered
 buffered datalink from 2 vectors to 1 More...
class  datalink_m2e
 Data link with a condition. More...
class  datalink_m2m
class  DS
 Abstract class for discrete-time sources of data. More...
class  BM
 Bayesian Model of a system, i.e. all uncertainty is modeled by probabilities. More...
class  MemDS
 Memory storage of off-line data column-wise (used mostly in C++). More...
class  FileDS
 Pseudovirtual class for reading data from files. More...
class  ITppFileDS
 Read Data Matrix from an IT file. More...
class  CsvFileDS
 CSV file data storage. More...
class  EpdfDS
 Simulate data from a static pdf (epdf). More...
class  PdfDS
 Simulate data from conditional density. More...
class  memlog
 Logging into matrices in data format in memory, optionally persisted into a file. More...
class  stdlog
 Simple logger used for debugging All data records are written out to std from where they could be send to file. More...
class  dirfilelog
 Logging into dirfile with buffer in memory. More...
class  Participant
 Basic Participant. More...
class  UIException
class  UISettingException
class  UIClassException
class  UIFile
 This class serves to load and/or save user-infos into/from configuration files stored on a hard-disk. More...
class  SettingResolver
 This class serves to expand links used within configuration files. More...
class  UI
 UI is an abstract class which collects all the auxiliary functions useful to prepare some concrete user-infos. More...
class  ParticularUI
class  root
 Root class of BDM objects. More...
class  log_level_base
class  LQG_ARX
 Controller using ARX model for estimation and LQG designer for control. More...
class  Controller
class  LQG
class  linfnEx
 extended class representing function $f(x) = Ax+B$ More...
class  LQG_universal
 Universal LQG controller. More...
class  ARX
 Linear Autoregressive model with Gaussian noise. More...
class  ARXls
 ARX moidel with parameters in LS form. More...
class  ARXfrg
 ARX model conditined by knowledge of the forgetting factor

\[ f( heta| d_1 \ldots d_t , \phi_t) \]

. More...

class  ARXmaxent
 ARX model with fixed maxent forgetting on increments,

\[ f( heta| d_1 \ldots d_t , \phi_t) \]

. More...

class  ARXwin
 ARX model with fixed-length window - old entries are removed

\[ f( heta| d_1 \ldots d_t) \]

. More...

class  ARXg
 Non-linear transformation + Gaussian noise. More...
struct  str_aux
struct  str_statistics
class  EKFful_unQR
 Extended Kalman filter with unknown Q and R. More...
class  EKFCh_dQ
 Extended Kalman filter in Choleski form with unknown diagonal Q. More...
class  EKFCh_chQ
 Extended Kalman filter in Choleski form with unknown Q. More...
class  StateSpace
 Basic elements of linear state-space model. More...
class  Kalman
 Common abstract base for Kalman filters. More...
class  KalmanFull
 Basic Kalman filter with full matrices. More...
class  KalmanCh
 Kalman filter in square root form. More...
class  EKFfull
 Extended Kalman Filter in full matrices. More...
class  EKFCh
 Extended Kalman Filter in Square root. More...
class  EKF_UD
 EKF using bierman and Thorton code. More...
class  UKFCh
class  MultiModel
 (Switching) Multiple Model The model runs several models in parallel and evaluates thier weights (fittness). More...
class  StateCanonical
 conversion of outer ARX model (mlnorm) to state space model More...
class  StateFromARX
class  MixEF
 Mixture of Exponential Family Densities. More...
class  ARXprod
 Product of ARX models forming an ARX model with potentially reduced structure. More...
class  MarginalizedParticleBase
 Abstract class for Marginalized Particles. More...
class  MarginalizedParticle
 Particle with marginalized subspace, used in PF. More...
class  BootstrapParticle
 Internal class which is used in PF. More...
class  PF
 Trivial particle filter with proposal density equal to parameter evolution model. More...
class  NoiseParticleX
class  NoiseParticleXY
class  NoiseParticleXYprop
class  NoiseParticle
class  chmat
 Symmetric matrix stored in square root decomposition using upper cholesky. More...
class  constfn
 class representing function $f(x) = a$, here rv is empty More...
class  linfn
 Class representing function $f(x) = Ax+B$. More...
class  quadraticfn
 Class representing function $ f(x) = [x' 1] Q [x' 1]' $ with Q in choleski decomposition. More...
class  diffbifn
 Class representing a differentiable function of two variables $f(x,u)$. More...
class  bilinfn
 Class representing function $f(x,u) = Ax+Bu$. More...
class  sqmat
 Abstract class for representation of double symmetric matrices in square-root form. More...
class  fsqmat
 Fake sqmat. This class maps sqmat operations to operations on full matrix. More...
class  ldmat
 Matrix stored in LD form, (commonly known as UD). More...
class  mxArrayDS
 DataSource reading data columns from a Matlab matrix. More...
class  mexFnc
class  mexlog
 Logger storing results into an mxArray. More...
class  ARXAgent
 ARX agent. More...
class  shared_ptr
 A naive implementation of roughly a subset of the std::tr1::shared_ptr spec. More...
class  object_ptr
 A wrapper of shared_ptr which is never empty. More...
class  support_base
class  rectangular_support
class  discrete_support
 Discrete support with stored support points. More...
class  grid_fnc
 Function defined by values on a fixed grid and interpolated inbetween them. More...
class  egrid
 Piecewise constant pdf on rectangular support. More...
class  mratio
 Class representing ratio of two densities. More...
class  emix_base
 Base class (interface) for mixtures. More...
class  emix
 Mixture of epdfs. More...
class  mprod
 Chain rule decomposition of epdf. More...
class  eprod_base
 Base class (interface) for bdm::eprod. More...
class  eprod
 Product of independent epdfs. For dependent pdfs, use bdm::mprod. More...
class  eprod_internal
 Internal class similar to eprod - factors are external pointers. To be used internally! More...
class  mmix
 Mixture of pdfs with constant weights, all pdfs are of equal RV and RVC. More...
class  ProdBMBase
 Base class for all BM running as parallel update of internal BMs. More...
class  ProdBM
class  ModelComparator
 class for on-line model selection More...
class  eEF
 Abstract class of general conjugate exponential family posterior density. More...
class  BMEF
 Estimator for Exponential family. More...
class  mgdirac
 Dirac delta density with predefined transformation. More...
class  enorm
 Gaussian density with positive definite (decomposed) covariance matrix. More...
class  estudent
class  egiw
 Gauss-inverse-Wishart density stored in LD form. More...
class  egw_ls
 Gauss-Wishart with recursion on moments Using precision as parameter following notation of [Karny Andrysek 2009], precision. More...
class  eDirich
 Dirichlet posterior density. More...
class  eBeta
 Product of Beta distributions. More...
class  mDirich
 Random Walk on Dirichlet. More...
class  mBeta
 Random Walk with vector Beta distribution. More...
class  multiBM
 Estimator for Multinomial density. More...
class  egamma
 Gamma posterior density. More...
class  eigamma
 Inverse-Gamma posterior density. More...
class  euni
 Uniform distributed density on a rectangular support. More...
class  mguni
 Uniform density with conditional mean value. More...
class  mlnorm
 Normal distributed linear function with linear function of mean value;. More...
class  mgnorm
 pdf with general function for mean value More...
class  mlstudent
 (Approximate) Student t density with linear function of mean value More...
class  mgamma
 Gamma random walk. More...
class  migamma
 Inverse-Gamma random walk. More...
class  mgamma_fix
 Gamma random walk around a fixed point. More...
class  migamma_ref
 Inverse-Gamma random walk around a fixed point. More...
class  elognorm
 Log-Normal probability density - it allows only diagonal covariances! More...
class  mlognorm
 Log-Normal random walk. More...
class  dirac
 Dirac delta function distribution. More...
class  MergerBase
 Abstract common class for mergers. More...
class  ENormMerger
 Merger into normal density, max entropy approximator for 2 moments (mean+variance). More...
class  MergerDiscrete
 Base class (interface) for for general combination of pdfs on discrete support. More...
class  merger_mix
 Merger using importance sampling with mixture proposal density. More...
class  egauss
 Gaussian (Normal) distribution. Same as enorm<fsqmat>. More...

Typedefs

typedef Array< shared_ptr<
epdf > > 
epdf_array
 array of pointers to epdf
typedef Array< shared_ptr<
pdf > > 
pdf_array
 array of pointers to pdf
typedef enorm< ldmategauss
typedef mlnorm< fsqmatmlgauss

Enumerations

enum  MixEF_METHOD { EM = 0, QB = 1 }
 enum switch for internal approximation used in MixEF
enum  MERGER_METHOD { ARITHMETIC = 1, GEOMETRIC = 2, LOGNORMAL = 3 }
 Merging methods.

Functions

std::ostream & operator<< (std::ostream &os, const RV &rv)
RV concat (const RV &rv1, const RV &rv2)
 Concat two random variables.
RV get_composite_rv (const Array< shared_ptr< pdf > > &pdfs, bool checkoverlap=false)
 Combines RVs from a list of pdfs to a single one.
 UIREGISTER (RV)
 SHAREDPTR (RV)
 SHAREDPTR (pdf)
 SHAREDPTR (epdf)
 UIREGISTER (MemDS)
 UIREGISTER (ITppFileDS)
 SHAREDPTR (ITppFileDS)
 UIREGISTER (EpdfDS)
 UIREGISTER (PdfDS)
 UIREGISTER (memlog)
 SHAREDPTR (memlog)
 UIREGISTER (stdlog)
 UIREGISTER (dirfilelog)
 SHAREDPTR (dirfilelog)
void bdm_assert_f (const std::string &ass, const std::string &msg, const std::string &file, int line)
 Helper function for the bdm_assert and bdm_assert_debug macros.
void bdm_error_f (const std::string &msg, const std::string &file, int line)
 Helper function for the bdm_error macro.
void bdm_warning_f (const std::string &msg, const std::string &file, int line)
 Helper function for the bdm_warning macro.
void UI_DBG (const Setting &S, const string &spc, ostream &out)
 auxiliary function for debugging
 UIREGISTER (LQG_ARX)
bool ldutg (mat &_utA, mat &_mB, mat &_mC)
double egiw_bestbelow (egiw Eg, egiw Eg0, double Egll, ivec &indices)
 Return the best structure.
 UIREGISTER (ARX)
 SHAREDPTR (ARX)
 UIREGISTER (ARXfrg)
 UIREGISTER (ARXmaxent)
 UIREGISTER (ARXwin)
 UIREGISTER (ARXg)
 SHAREDPTR (ARXg)
void str_bitset (bvec &out, ivec ns, int nbits)
double seloglik1 (str_aux in)
void sedydr (mat &r, mat &f, double &Dr, double &Df, int R)
void seswapudl (mat &L, vec &d, int i)
void str_bitres (bvec &out, ivec ns, int nbits)
str_aux sestrremove (str_aux in, ivec removed_elements)
ivec setdiff (ivec a, ivec b)
void add_new (Array< str_aux > &global_best, str_aux newone, int nbest)
str_aux sestrinsert (str_aux in, ivec inserted_elements)
double seloglik2 (str_aux in)
ivec straux1 (ldmat Ld, double nu, ldmat Ld0, double nu0, ivec belief, int nbest, int max_nrep, double lambda, int order_k, Array< str_aux > &rgrsout)
 Replication of Ludvik Tesar original straux1 from mixtools straux1.
 UIREGISTER (KalmanFull)
 UIREGISTER (KalmanCh)
 UIREGISTER (EKFfull)
 UIREGISTER (EKFCh)
 SHAREDPTR (EKFCh)
 UIREGISTER (EKF_UD)
 UIREGISTER (UKFCh)
 UIREGISTER (MultiModel)
 SHAREDPTR (MultiModel)
 UIREGISTER (MixEF)
 UIREGISTER (ARXprod)
 UIREGISTER (MarginalizedParticle)
 UIREGISTER (BootstrapParticle)
 UIREGISTER (PF)
 UIREGISTER (NoiseParticleX)
 UIREGISTER (NoiseParticleXY)
 UIREGISTER (NoiseParticleXYprop)
 UIREGISTER (NoiseParticle)
 UIREGISTER (linfn)
 UIREGISTER (quadraticfn)
 UIREGISTER (bilinfn)
std::ostream & operator<< (std::ostream &os, const fsqmat &ld)
std::ostream & operator<< (std::ostream &os, const ldmat &ld)
mat ltuinv (const mat &L)
 Auxiliary function ltuinv; inversion of a triangular matrix;.
void dydr (double *r, double *f, double *Dr, double *Df, double *R, int jl, int jh, double *kr, int m, int mx)
 Auxiliary function dydr; dyadic reduction.
 UIREGISTER (mxArrayDS)
 SHAREDPTR (mxArrayDS)
 UIREGISTER (mexFnc)
int mxReplaceFieldNM (mxArray *X, const char *fname, mxArray *X1)
void Arrayvec2mxArray (const Array< vec > &in, mxArray *out)
 UIREGISTER (mexlog)
 SHAREDPTR (mexlog)
 UIREGISTER (ARXAgent)
template<typename T, typename U>
bool operator== (shared_ptr< T > const &a, shared_ptr< U > const &b)
 Compare shared pointers.
template<typename T, typename U>
bool operator!= (shared_ptr< T > const &a, shared_ptr< U > const &b)
 Compare shared pointers.
template<typename T, typename U>
bool operator< (shared_ptr< T > const &a, shared_ptr< U > const &b)
 Compare shared pointers.
 UIREGISTER (support_base)
 UIREGISTER (rectangular_support)
 UIREGISTER (discrete_support)
 UIREGISTER (grid_fnc)
 SHAREDPTR (emix)
 UIREGISTER (emix)
 UIREGISTER (mprod)
 SHAREDPTR (mprod)
 UIREGISTER (eprod)
 SHAREDPTR (mmix)
 UIREGISTER (mmix)
 UIREGISTER (ProdBM)
void resample (const vec &w, ivec &ind, RESAMPLING_METHOD method)
 UIREGISTER (mgdirac)
 UIREGISTER2 (enorm, chmat)
 SHAREDPTR2 (enorm, chmat)
 UIREGISTER2 (enorm, ldmat)
 SHAREDPTR2 (enorm, ldmat)
 UIREGISTER2 (enorm, fsqmat)
 SHAREDPTR2 (enorm, fsqmat)
 UIREGISTER (egauss)
 UIREGISTER2 (estudent, fsqmat)
 UIREGISTER2 (estudent, ldmat)
 UIREGISTER2 (estudent, chmat)
 UIREGISTER (egiw)
 SHAREDPTR (egiw)
 UIREGISTER (eDirich)
 UIREGISTER (eBeta)
 UIREGISTER (mDirich)
 UIREGISTER (mBeta)
 UIREGISTER (multiBM)
 UIREGISTER (egamma)
 SHAREDPTR (egamma)
 UIREGISTER (euni)
 UIREGISTER (mguni)
 UIREGISTER2 (mlnorm, ldmat)
 SHAREDPTR2 (mlnorm, ldmat)
 UIREGISTER2 (mlnorm, fsqmat)
 SHAREDPTR2 (mlnorm, fsqmat)
 UIREGISTER2 (mlnorm, chmat)
 SHAREDPTR2 (mlnorm, chmat)
 UIREGISTER (mlgauss)
 UIREGISTER2 (mgnorm, chmat)
 UIREGISTER2 (mgnorm, ldmat)
 SHAREDPTR2 (mgnorm, chmat)
 UIREGISTER (mgamma)
 SHAREDPTR (mgamma)
 UIREGISTER (migamma_ref)
 SHAREDPTR (migamma_ref)
 UIREGISTER (mlognorm)
 SHAREDPTR (mlognorm)
void from_setting (const Setting &set)
 Inverse Wishart density defined on Choleski decomposition.
 UIREGISTER (eEmp)
template<class sq_T>
std::ostream & operator<< (std::ostream &os, mlnorm< sq_T > &ml)
 odo unify this stuff with to_string()
 UIREGISTER (MergerDiscrete)
 SHAREDPTR (MergerDiscrete)
 UIREGISTER (merger_mix)
 SHAREDPTR (merger_mix)

Variables

const bool STRICT_RV = true
Uniform_RNG UniRNG
 Global Uniform_RNG.
Normal_RNG NorRNG
 Global Normal_RNG.
Gamma_RNG GamRNG
 Global Gamma_RNG.
Uniform_RNG UniRNG
 Global Uniform_RNG.
Normal_RNG NorRNG
 Global Normal_RNG.
Gamma_RNG GamRNG
 Global Gamma_RNG.

Detailed Description

Space of basic BDM structures.

Function Documentation

bool bdm::ldutg ( mat &  _utA,
mat &  _mB,
mat &  _mC 
) [inline]

left matrix division with upper triangular matrix using Gauss elimination fast variant of inv(A) * B where A is UT matrix, returns result in C and true if no error

double bdm::egiw_bestbelow ( egiw  Eg,
egiw  Eg0,
double  Egll,
ivec &  indices 
)

Return the best structure.

Parameters:
Eg a copy of GiW density that is being examined
Eg0 a copy of prior GiW density before estimation
Egll likelihood of the current Eg
indices current indices
Returns:
best likelihood in the structure below the given one

void bdm::from_setting ( const Setting &  set  ) 

Inverse Wishart density defined on Choleski decomposition.

here $\Omega \sim |\Sigma|^{-0.5(\delta}|\Omega|^{0.5(\delta -p -1)} \exp(-1/2 tr(\Omega\Sigma^{-1}))\$f */ class eWishartCh : public epdf { protected: //! Upper-Triagle of Choleski decomposition of $ $ chmat Sigma; //! dimension of matrix $ $ int p; //! degrees of freedom $ $ double delta; public: //! Set internal structures void set_parameters ( const mat &Y0, const double delta0 ) { Sigma = chmat ( Y0 ); delta = delta0; p = Sigma.rows(); } //! Set internal structures void set_parameters ( const chmat &Y0, const double delta0 ) { Sigma = Y0; delta = delta0; p = Sigma.rows(); } virtual void validate () { epdf::validate(); dim = p * p; } //! Sample matrix argument - lower //! Using Bartlet decomposition: W=L A A^T L^T where A is lower triag and L is choleski factor of Sigma. chmat sample_mat() const { mat A_T = zeros ( p, p ); // A transpose //sample diagonal for ( int i = 0; i < p; i++ ) { GamRNG.setup ( 0.5* ( delta - i ) , 0.5 ); // no +1 !! index if from 0 A_T ( i, i ) = sqrt ( GamRNG() ); } //do the rest for ( int i = 0; i < p; i++ ) { for ( int j = i + 1; j < p; j++ ) { A_T ( i, j ) = NorRNG.sample(); } } chmat tmp; tmp._Ch()=A_T*Sigma._Ch(); return tmp;// return upper triangular part of the decomposition } vec sample () const { return vec ( sample_mat().to_mat()._data(), p*p ); } virtual vec mean() const NOT_IMPLEMENTED(0); //! return expected variance (not covariance!) virtual vec variance() const NOT_IMPLEMENTED(0); virtual double evallog ( const vec &val ) const NOT_IMPLEMENTED(0); //! fast access function y0 will be copied into Y.Ch. void setY ( const mat &Ch0 ) { copy_vector ( dim, Ch0._data(), Sigma._Ch()._data() ); } //! fast access function y0 will be copied into Y.Ch. void _setY ( const vec &ch0 ) { copy_vector ( dim, ch0._data(), Sigma._Ch()._data() ); } //! access function const chmat& getY() const { return Sigma; } }; //! Inverse Wishart on Choleski decomposition /*! Being computed by conversion from `standard' Wishart */ class eiWishartCh: public epdf { protected: //! Internal instance of Wishart density eWishartCh W; //! size of Ch int p; //! parameter delta double delta; public: //! constructor function void set_parameters ( const mat &Y0, const double delta0 ) { delta = delta0; W.set_parameters ( inv ( Y0 ), delta0 ); p = Y0.rows(); } virtual void validate () { epdf::validate(); W.validate(); dim = W.dimension(); } vec sample() const { mat iCh; iCh = inv ( W.sample_mat()._Ch() ); return vec ( iCh._data(), dim ); } //! access function void _setY ( const vec &y0 ) { mat Ch ( p, p ); mat iCh ( p, p ); copy_vector ( dim, y0._data(), Ch._data() ); iCh = inv ( Ch ); W.setY ( iCh ); } virtual double evallog ( const vec &val ) const { chmat X ( p ); const chmat& Y = W.getY(); copy_vector ( p*p, val._data(), X._Ch()._data() ); chmat iX ( p ); X.inv ( iX ); // compute // \frac{ |\Psi|^{m/2}|X|^{-(m+p+1)/2}e^{-tr(\Psi X^{-1})/2} }{ 2^{mp/2}\Gamma_p(m/2)}, mat M = Y.to_mat() * iX.to_mat(); double log1 = 0.5 * p * ( 2 * Y.logdet() ) - 0.5 * ( delta + p + 1 ) * ( 2 * X.logdet() ) - 0.5 * trace ( M ); //Fixme! Multivariate gamma omitted!! it is ok for sampling, but not otherwise!! /* if (0) { mat XX=X.to_mat(); mat YY=Y.to_mat(); double log2 = 0.5*p*log(det(YY))-0.5*(delta+p+1)*log(det(XX))-0.5*trace(YY*inv(XX)); cout << log1 << "," << log2 << endl; }*/ return log1; }; virtual vec mean() const NOT_IMPLEMENTED(0); //! return expected variance (not covariance!) virtual vec variance() const NOT_IMPLEMENTED(0); }; //! Random Walk on inverse Wishart class rwiWishartCh : public pdf_internal<eiWishartCh> { protected: //!square root of $ -p-1 $ - needed for computation of $ $ from conditions double sqd; //!reference point for diagonal vec refl; //! power of the reference double l; //! dimension int p; public: rwiWishartCh() : sqd ( 0 ), l ( 0 ), p ( 0 ) {} //! constructor function void set_parameters ( int p0, double k, vec ref0, double l0 ) { p = p0; double delta = 2 / ( k * k ) + p + 3; sqd = sqrt ( delta - p - 1 ); l = l0; refl = pow ( ref0, 1 - l ); iepdf.set_parameters ( eye ( p ), delta ); }; void validate() { pdf_internal<eiWishartCh>::validate(); dimc = iepdf.dimension(); } void condition ( const vec &c ) { vec z = c; int ri = 0; for ( int i = 0; i < p*p; i += ( p + 1 ) ) {//trace diagonal element z ( i ) = pow ( z ( i ), l ) * refl ( ri ); ri++; } iepdf._setY ( sqd*z ); } }; //! Switch between various resampling methods. enum RESAMPLING_METHOD { MULTINOMIAL = 0, STRATIFIED = 1, SYSTEMATIC = 3 }; //! Shortcut for multinomial.sample(int n). Various simplifications are allowed see RESAMPLING_METHOD void resample(const vec &w, ivec &ind, RESAMPLING_METHOD=SYSTEMATIC); /*! \brief Weighted empirical density Used e.g. in particle filters. */ class eEmp: public epdf { protected : //! Number of particles int n; //! Sample weights $w$ vec w; ! Samples $x^{(i)}, i=1..n


Generated on 2 Dec 2013 for mixpp by  doxygen 1.4.7