# bdm::PF Class Reference

Trivial particle filter with proposal density equal to parameter evolution model. More...

## Detailed Description

Trivial particle filter with proposal density equal to parameter evolution model.

Posterior density is represented by a weighted empirical density (`eEmp` ).

`#include <particles.h>`

List of all members.

## Public Member Functions
void | set_options (const string &opt)
virtual void | bayes_gensmp ()
| bayes I - generate samples and add their weights to lls
virtual void | bayes_weights ()
| bayes II - compute weights of the
virtual bool | do_resampling ()
| important part of particle filtering - decide if it is time to perform resampling
void | bayes (const vec &dt)
| Incremental Bayes rule.
vec & | __w ()
| access function
vec & | _lls ()
| access function
RESAMPLING_METHOD | _resmethod () const
const eEmp & | posterior () const
| access function
void | from_setting (const Setting &set)
void | resmethod_from_set (const Setting &set)
| auxiliary function reading parameter 'resmethod' from configuration file
void | prior_from_set (const Setting &set)
| load prior information from set and set internal structures accordingly
void | validate ()
| This method TODO.
void | resample (ivec &ind)
| resample posterior density (from outside - see MPF)
Array< vec > & | __samples ()
virtual string | to_string ()
| This method returns a basic info about the current instance.
virtual void | to_setting (Setting &set) const
| This method save all the instance properties into the Setting structure.
Constructors
| PF ()
void | set_parameters (int n0, double res_th0=0.5, RESAMPLING_METHOD rm=SYSTEMATIC)
void | set_model (shared_ptr< mpdf > par0, shared_ptr< mpdf > obs0)
void | set_statistics (const vec w0, const epdf &epdf0)
void | set_statistics (const eEmp &epdf0)
Constructors
virtual BM * | _copy_ () const
| Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! Prototype:.
Mathematical operations
virtual void | bayesB (const mat &Dt)
| Batch Bayes rule (columns of Dt are observations).
virtual double | logpred (const vec &dt) const
vec | logpred_m (const mat &dt) const
| Matrix version of logpred.
virtual epdf * | epredictor () const
| Constructs a predictive density .
virtual mpdf * | predictor () const
| Constructs conditional density of 1-step ahead predictor .
Access to attributes
const RV & | _drv () const
void | set_drv (const RV &rv)
void | set_rv (const RV &rv)
double | _ll () const
void | set_evalll (bool evl0)
## Protected Attributes
int | n
| number of particles;
eEmp | est
| posterior density
vec & | _w
| pointer into `eEmp`
Array< vec > & | _samples
| pointer into `eEmp`
shared_ptr< mpdf > | par
| Parameter evolution model.
shared_ptr< mpdf > | obs
| Observation model.
vec | lls
| internal structure storing loglikelihood of predictions
RESAMPLING_METHOD | resmethod
| which resampling method will be used
double | res_threshold
RV | drv
| Random variable of the data (optional).
double | ll
| Logarithm of marginalized data likelihood.
bool | evalll
| If true, the filter will compute likelihood of the data record and store it in `ll` . Set to false if you want to save computational time.
Options
bool | opt_L_smp
| Log all samples.
bool | opt_L_wei
| Log all samples.
## Extension to conditional BM
This extension is useful e.g. in Marginalized Particle Filter (bdm::MPF). Alternatively, it can be used for automated connection to DS when the condition is observed
const RV & | _rvc () const
| access function
virtual void | condition (const vec &val)
| Substitute `val` for `rvc`.
RV | rvc
| Name of extension variable.
## Logging of results
virtual void | log_add (logger &L, const string &name="")
| Add all logged variables to a logger.
virtual void | logit (logger &L)
| Save results to the given logger, details of what is stored is configured by `LIDs` and `options`.
ivec | LIDs
| IDs of storages in loggers 4:[1=mean,2=lb,3=ub,4=ll].
ivec | LFlags
| Flags for logging - same size as LIDs, each entry correspond to the same in LIDs.

## Member Function Documentation

virtual BM* bdm::BM::_copy_ | ( |  | ) | const`[inline, virtual, inherited]`

Copy function required in vectors, Arrays of BM etc. Have to be DELETED manually! Prototype:.

     BM* _copy_() const {return new BM(*this);}

Reimplemented in bdm::ARX, bdm::ARXfrg, bdm::KalmanFull, bdm::KalmanCh, bdm::EKFCh, and bdm::BMEF.

void bdm::PF::bayes | ( | const vec & | dt | ) | `[virtual]`

Incremental Bayes rule.

Parameters:

  | dt | vector of input data

Implements bdm::BM.

References _samples, bayes_gensmp(), bayes_weights(), do_resampling(), est, lls, n, obs, bdm::eEmp::resample(), and resmethod.

void bdm::PF::from_setting | ( | const Setting & | set | ) | `[inline, virtual]`

configuration structure for basic PF

            parameter_pdf   = mpdf_class;         // parameter evolution pdf
            observation_pdf = mpdf_class;         // observation pdf
            prior           = epdf_class;         // prior probability density
            --- optional ---
            n               = 10;                 // number of particles
            resmethod       = 'systematic', or 'multinomial', or 'stratified'
                                                                                      // resampling method
            res_threshold   = 0.5;                // resample when active particles drop below 50%

Reimplemented from bdm::BM.

References bdm::RV::add(), obs, par, prior_from_set(), and resmethod_from_set().

virtual double bdm::BM::logpred | ( | const vec & | dt | ) | const`[inline, virtual, inherited]`

Evaluates predictive log-likelihood of the given data record I.e. marginal likelihood of the data with the posterior integrated out.

Reimplemented in bdm::ARX, bdm::MixEF, and bdm::multiBM.

References bdm_error.

Referenced by bdm::BM::logpred_m().

void bdm::PF::set_options | ( | const string & | opt | ) | `[inline, virtual]`

Set posterior density by sampling from epdf0 Extends original BM::set_options by two more options:

- logweights - meaning that all weightes will be logged
- logsamples - all samples will be also logged

Reimplemented from bdm::BM.

References opt_L_smp, and opt_L_wei.

## Member Data Documentation

double bdm::PF::res_threshold`[protected]`

resampling threshold; in this case its meaning is minimum ratio of active particles For example, for 0.5 resampling is performed when the numebr of active aprticles drops belo 50%.

Referenced by do_resampling(), and resmethod_from_set().

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

- particles.h
- particles.cpp