This is a brief introduction into elements used in the BDM. The toolbox was designed for two principle tasks:

\begin{itemize}
\item Design of Bayesian decisions-making startegies,  \item Bayesian system identification for on-line and off-line scenarios.  \end{itemize}
Theoretically, the latter is a special case of the former, however we list it separately to highlight its importance in practical applications.

In order to achieve these principal goals in full generality, we need to implement full range of probabilistic operations such as: marginalization, conditioning, Bayes rule, combination of probability densities. Furthermore, many supportive operations are also required, such as data handling and logging of results. Here, we explain the basic classes for each task and point to advanced topics on the issue.\hypertarget{intro_phil}{}\section{Philosophy of the Toolbox}\label{intro_phil}
The primary obstacle for creation of any any Bayesian software is how to address inherent computational intractability of the calculus. Typically, toolboxes implementing Bayesian calculus choose one particular task or one particular approximation methodology. For example, \char`\"{}BUGS\char`\"{} is a toolbox focused on evaluation using Gibbs sampling, \char`\"{}BNT\char`\"{} is focused on Bayesian Networks, \char`\"{}NFT\char`\"{} on Bayesian filtering. BDM takes another approach: {\bf  all tasks are defined via their functional form, detailed implementation is an internal matter of each class.}

This philosophy results in a tree structure of inheritance, where the root is an abstract class. Different approaches to Bayesian calculus are implemented as specialization of this class. Interoperability of these classes is achieved by data classes, representing mathematical objects arising in the Bayesian calculus.

The task of Bayesian estimation decribed in the next Section is a good illustration of the philosophy.\hypertarget{intro_bayes}{}\section{Bayesian parameter estimation}\label{intro_bayes}
Bayesian parameter estimation is, in essence, straightforward application of the Bayes rule:\[ f(\theta|D) =\frac{f(D|\theta)f(\theta)}{f(D)}\] where, $ \theta $ is an unknown parameter, $ D $ denotes the observed data, $ f(D|\theta) $ is the likelihood function, $ f(\theta) $ is the prior density, and $ f(D) $ is \char`\"{}evidence\char`\"{} of the data.

This simple rule has, however, many incarnations for various types of the likelihood, prior and evidence. For example, the Bayes rule can be evaluated exactly for likelihood function from the Exponential Family and conjugate prior, where the whole functional operation reduces to algebraic operation on sufficient statistics. For other likelihood functions and priors, various approximate schemes (such as Monte Carlo sampling, or maximum-likelihood optimizations) were proposed. To capture all of these options, we abstract the core functionality in the class {\tt \hyperlink{classBM}{BM}:} 

\begin{description}
\end{description}
\hyperlink{classBM}{BM}, abstract class defining two key methods: \begin{itemize}
\item 

\begin{Code}\begin{verbatim} void bayes(vec dt) 
\end{verbatim}
\end{Code}

 or 

\begin{Code}\begin{verbatim} void bayesB(mat D) 
\end{verbatim}
\end{Code}

  \item 

\begin{Code}\begin{verbatim} epdf& _epdf(). 
\end{verbatim}
\end{Code}

  \end{itemize}


Hence, the class represent an \char`\"{}estimator\char`\"{} that is capable of returning a posterior density (via method {\tt \_\-epdf} ) and application of the Bayes rule vis method {\tt bayes} .

Functions {\tt bayes} and {\tt bayesB} denotes on-line and off-line scenario, respectively. Function {\tt bayes} assumes that \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em dt}]is an incremental data record and applies the Bayes rule using posterior density for the previous step as a prior. On the other hand, {\tt bayesB} assumes that \item[{\em D}]is the full data record, and uses the original prior created during construction of the object.\end{description}
\end{Desc}
Posterior density is represented by a class {\tt \hyperlink{classepdf}{epdf}} . When we are interested only in part of the posterior density we can apply probability calculus via methods of this class.\hypertarget{intro_calc}{}\section{Probability calculus}\label{intro_calc}
Key objects of probability calculus are probability density functions, pdfs. We distinguish two types of pdfs: \begin{description}
\end{description}
\hyperlink{classepdf}{epdf}, a pdf fully defined by statistics: $ f(a | S)$, with numerical statics $ S $, and   \hyperlink{classmpdf}{mpdf}, a pdf conditioned on another random variable: $ f(a| b) $, where $ b $ is a variable. 

The principal distinction between these types is that operations defined on these classes have different results. For example, the first moment of the former is a numeric value, while for the latter it is a functional form.

The most important operations on pdfs are: \begin{description}
\end{description}
evaluation in a point: implemented by methods 

\begin{Code}\begin{verbatim} double evallog(vec dt)
\end{verbatim}
\end{Code}

 for {\tt \hyperlink{classepdf}{epdf}} and 

\begin{Code}\begin{verbatim} double evallogcond()
\end{verbatim}
\end{Code}

 for {\tt \hyperlink{classmpdf}{mpdf}}.   marginalization: implemented by method 

\begin{Code}\begin{verbatim} epdf* marginal(RV rv)
\end{verbatim}
\end{Code}

 for \hyperlink{classepdf}{epdf},   conditioning: implemented by method 

\begin{Code}\begin{verbatim} mpdf* conditional(RV rv)
\end{verbatim}
\end{Code}

 for \hyperlink{classepdf}{epdf}.  

Note that a new data class, {\tt \hyperlink{classRV}{RV}}, is introduced. This class represents description of a multivariate random variable.\hypertarget{intro_RVs}{}\section{Random Variables}\label{intro_RVs}
In mathematics, variable is a symbol of quantity that has no assigned value. Its purpose is to distinguish one variable from another. Hence, in software representation it has a meaning of unique identifier. Since we allow multivariate random variables, the variable also carries its dimensionality. Moreover, for dealing with time-varying estimation it also makes sense to distinguish different time-shift of variables.

The main purpose of this class is to mediate composition and decomposition of pdfs. See,... 