This is a brief introduction into elements used in the BDM. The toolbox was designed for two principle tasks:
Theoretically, the latter is a special case of the former, however we list it separately to highlight its importance in practical applications.
Here, we describe basic objects that are required for implementation of the Bayesian parameter estimation.
Key objects are:
BM
epdf
The class BM is designed for both on-line and off-line estimation. We make the following assumptions about data:
vec
dt
, mat
D
, where each column represent one individual data record On-line estimation is implemented by method
void bayes(vec dt)
Off-line estimation is implemented by method
void bayesB(mat D)
As an intermediate product, the bayes rule computes marginal likelihood of the data records . Numerical value of this quantity which is important e.g. for model selection can be obtained by calling method _ll()
.
Class BM
offers several ways how to obtain results:
_epdf()
and predictor()
logpred()
Underscore in the name of method _epdf()
indicate that the method returns a pointer to the internal posterior density of the model. On the other hand, predictor
creates a new structure of type epdf()
.
Direct evaluation of predictive pdfs via logpred offers a shortcut for more efficient implementation.
As introduced above, the results of parameter estimation are in the form of probability density function conditioned on numerical values. This type of information is represented by class epdf
.
This class allows such as moment evaluation via methods mean()
and variance()
, marginalization via method marginal()
, and conditioning via method condition()
.
Also, it allows generation of a sample via sample()
and evaluation of one value of the posterior parameter likelihood via evallog()
. Multivariate versions of these operations are also available by adding suffix _m
, i.e. sample_m()
and evallog_m()
. These methods providen multiple samples and evaluation of likelihood in multiple points respectively.
When a more demanding task then generation of point estimate of the parameter is required, the power of general probability claculus can be used. The following classes (together with epdf
introduced above) form the basis of the calculus:
mpdf
a pdf conditioned on another symbolic variable, RV
a symbolic variable on which pdfs are defined. The former class is an extension of mpdf that allows conditioning on a symbolic variable. Hence, when numerical results - such as samples - are required, numericla values of the condition must be provided. The names of methods of the epdf
are used extended by suffix cond
, i.e. samplecond()
, evallogcond()
, where cond
precedes matrix estension, i.e. samplecond_m()
and evallogcond_m()
.
The latter class is used to identify how symbolic variables are to be combined together. For example, consider the task of composition of pdfs via the chain rule:
In our setup, is represented by an mpdf
while and by two epdfs
. We need to distinguish the latter two from each other and to deside in which order they should be added to the mpdf. This distinction is facilitated by the class RV
which uniquely identify a random varibale.
Therefore, each pdf keeps record on which RVs it represents; epdf
needs to know only one RV
stored in the attribute rv
; mpdf
needs to keep two RVs
, one for variable on which it is defined (rv
) and one for variable incondition which is stored in attribute rvc
.