# bdm::merger_base Class Reference

Base class for general combination of pdfs on discrete support. More...

## Detailed Description

Base class for general combination of pdfs on discrete support.

Mixtures of Gaussian densities are used internally. Switching to other densities should be trivial.

The merged pdfs are expected to be of the form:

where the resulting merger is a density on . Note that all variables will be joined.

As a result of this feature, each source must be extended to common support

where accumulate variables that were not in the original source. These extensions are calculated on-the-fly.

However, these operations can not be performed in general. Hence, this class merges only sources on common support, . For merging of more general cases, use offsprings merger_mix and merger_grid.

`#include <merger.h>`

List of all members.

## Public Member Functions
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
| merger_base ()
| Default constructor.
| merger_base (const Array< shared_ptr< mpdf > > &S)
| Constructor from sources.
void | set_sources (const Array< shared_ptr< mpdf > > &Sources)
| Function setting the main internal structures.
void | set_support (rectangular_support &Sup)
| Set support points from rectangular grid.
void | set_support (discrete_support &Sup)
| Set support points from dicrete grid.
void | set_debug_file (const string fname)
| set debug file
void | set_method (MERGER_METHOD MTH=DFLT_METHOD, double beta0=DFLT_beta)
| Set internal parameters used in approximation.
void | set_support (const epdf &overall, int N)
| Set support points from a pdf by drawing N samples.
virtual | ~merger_base ()
| Destructor.
Mathematical operations
virtual void | merge ()
| Merge given sources in given points.
vec | merge_points (mat &lW)
| Merge log-likelihood values in points using method specified by parameter METHOD.
vec | mean () const
| weight w is a
mat | covariance () const
vec | variance () const
| return expected variance (not covariance!)
Access to attributes
eEmp & | _Smp ()
| Access function.
void | from_setting (const Setting &set)
| load from setting
void | validate ()
| This method TODO.
Constructors
Construction of each epdf should support two types of constructors: empty constructor, copy constructor, The following constructors should be supported for convenience: constructor followed by calling `set_parameters()` constructor accepting random variables calling `set_rv()` All internal data structures are constructed as empty. Their values (including sizes) will be set by method `set_parameters()`. This way references can be initialized in constructors.
void | set_parameters (int dim0)
Matematical Operations
virtual vec | sample () const
| Returns a sample, from density .
virtual mat | sample_m (int N) const
| Returns N samples, from density .
virtual double | evallog (const vec &val) const
| Compute log-probability of argument `val` In case the argument is out of suport return -Infinity.
virtual vec | evallog_m (const mat &Val) const
| Compute log-probability of multiple values argument `val`.
virtual vec | evallog_m (const Array< vec > &Avec) const
| Compute log-probability of multiple values argument `val`.
virtual shared_ptr< mpdf > | condition (const RV &rv) const
| Return conditional density on the given RV, the remaining rvs will be in conditioning.
virtual shared_ptr< epdf > | marginal (const RV &rv) const
| Return marginal density on the given RV, the remainig rvs are intergrated out.
virtual void | qbounds (vec &lb, vec &ub, double percentage=0.95) const
| Lower and upper bounds of `percentage` % quantile, returns mean-2*sigma as default.
Connection to other classes
Description of the random quantity via attribute `rv` is optional. For operations such as sampling `rv` does not need to be set. However, for `marginalization` and `conditioning` `rv` has to be set. NB:
void | set_rv (const RV &rv0)
| Name its rv.
bool | isnamed () const
| True if rv is assigned.
const RV & | _rv () const
| Return name (fails when isnamed is false).
Access to attributes
int | dimension () const
| Size of the random variable.
## Protected Attributes
Array< shared_ptr< mpdf > > | mpdfs
| Elements of composition.
Array< datalink_m2e * > | dls
| Data link for each mpdf in mpdfs.
Array< RV > | rvzs
| Array of rvs that are not modelled by mpdfs at all, .
Array< datalink_m2e * > | zdls
| Data Links for extension .
int | Npoints
| number of support points
int | Nsources
| number of sources
MERGER_METHOD | METHOD
| switch of the methoh used for merging
double | beta
| Prior on the log-normal merging model.
eEmp | eSmp
| Projection to empirical density (could also be piece-wise linear).
bool | DBG
| debug or not debug
it_file * | dbg_file
| debugging file
int | dim
| dimension of the random variable
RV | rv
| Description of the random variable.
## Static Protected Attributes
static const MERGER_METHOD | DFLT_METHOD = LOGNORMAL
| Default for METHOD.
static const double | DFLT_beta = 1.2
| default for beta

## Member Function Documentation

vec bdm::merger_base::mean | ( |  | ) | const`[inline, virtual]`

weight w is a

sample from merged density

Reimplemented from bdm::epdf.

References bdm::eEmp::_samples(), bdm::eEmp::_w(), bdm::epdf::dim, eSmp, and Npoints.

Referenced by variance().

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

- merger.h
- merger.cpp