Here, we describe basic objects that are required for implementation of the Bayesian parameter estimation.
Key objects are:
BM
epdf
vec
dt
, mat
D
, where each column represent one individual data record On-line estimation is implemented by method
void bayes(vec dt)
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()
.
BM
offers several ways how to obtain results: _epdf()
and predictor()
logpred()
_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.
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.
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
.