# bdm::mratio Class Reference

Class representing ratio of two densities which arise e.g. by applying the Bayes rule. It represents density in the form:

where . More...

## Detailed Description

Class representing ratio of two densities which arise e.g. by applying the Bayes rule. It represents density in the form:

where .

In particular this type of arise by conditioning of a mixture model.

At present the only supported operation is evallogcond().

`#include <emix.h>`

List of all members.

## Public Member Functions
| mratio (const epdf *nom0, const RV &rv, bool copy=false)
double | evallogcond (const vec &val, const vec &cond)
| Shortcut for conditioning and evaluation of the internal epdf. In some cases, this operation can be implemented efficiently.
void | ownnom ()
| Object takes ownership of nom and will destroy it.
| ~mratio ()
| Default destructor.
void | from_setting (const Setting &set)
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.
virtual void | validate ()
| This method TODO.
Matematical operations
virtual vec | samplecond (const vec &cond)
| Returns a sample from the density conditioned on `cond`, .
virtual mat | samplecond_m (const vec &cond, int N)
| Returns.
virtual vec | evallogcond_m (const mat &Dt, const vec &cond)
| Matrix version of evallogcond.
virtual vec | evallogcond_m (const Array< vec > &Dt, const vec &cond)
| Array<vec> version of evallogcond.
Access to attributes
const RV & | _rv () const
const RV & | _rvc () const
int | dimension () const
int | dimensionc ()
Connection to other objects
void | set_rvc (const RV &rvc0)
void | set_rv (const RV &rv0)
bool | isnamed ()
## Protected Member Functions
void | set_ep (epdf &iepdf)
| set internal pointer `ep` to point to given `iepdf`
void | set_ep (epdf *iepdfp)
| set internal pointer `ep` to point to given `iepdf`
## Protected Attributes
const epdf * | nom
| Nominator in the form of mpdf.
shared_ptr< epdf > | den
| Denominator in the form of epdf.
bool | destroynom
| flag for destructor
datalink_m2e | dl
| datalink between conditional and nom
epdf | iepdf
| dummy epdf that stores only rv and dim
int | dimc
| dimension of the condition
RV | rvc
| random variable in condition

## Constructor & Destructor Documentation

bdm::mratio::mratio | ( | const epdf * | nom0,
|  | const RV & | rv,
|  | bool | copy = `false` |
| ) |  |  | `[inline]`

Default constructor. By default, the given epdf is not copied! It is assumed that this function will be used only temporarily.

References bdm::RV::_dsize(), bdm::epdf::_rv(), bdm_assert_debug, bdm_error, den, destroynom, bdm::mpdf::dimc, dl, iepdf, bdm::RV::length(), bdm::epdf::marginal(), nom, bdm::mpdf::rvc, bdm::datalink_m2e::set_connection(), bdm::mpdf::set_ep(), bdm::epdf::set_rv(), and bdm::RV::subt().

## Member Function Documentation

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

Load from structure with elements:

     { class = "mpdf_offspring",
       rv = {class="RV", names=(...),}; // RV describing meaning of random variable
       rvc= {class="RV", names=(...),}; // RV describing meaning of random variable in condition
       // elements of offsprings
     }

Reimplemented from bdm::root.

Reimplemented in bdm::mepdf, bdm::mprod, bdm::mDirich, bdm::mlnorm< sq_T, TEpdf >, bdm::mgnorm< sq_T >, bdm::mgamma, bdm::migamma_ref, bdm::mlognorm, and bdm::mlnorm< ldmat, enorm >.

virtual vec bdm::mpdf::samplecond | ( | const vec & | cond | ) | `[inline, virtual, inherited]`

Returns a sample from the density conditioned on `cond`, .

Parameters:

  | cond | is numeric value of `rv`

Reimplemented in bdm::mpdf_internal< EPDF >, bdm::mepdf, bdm::mprod, bdm::mmix, bdm::mpdf_internal< eDirich >, bdm::mpdf_internal< enorm< sq_T > >, bdm::mpdf_internal< elognorm >, bdm::mpdf_internal< TEpdf< sq_T > >, bdm::mpdf_internal< egamma >, bdm::mpdf_internal< enorm< ldmat > >, bdm::mpdf_internal< eiWishartCh >, and bdm::mpdf_internal< eigamma >.

References bdm_error.

Referenced by bdm::mpdf::samplecond_m().

mat bdm::mpdf::samplecond_m | ( | const vec & | cond,
|  | int | N |
| ) |  |  | `[virtual, inherited]`

Returns.

Parameters:

  | N | samples from the density conditioned on `cond`, .
  | cond | is numeric value of `rv`

Reimplemented in bdm::mpdf_internal< EPDF >, bdm::mpdf_internal< eDirich >, bdm::mpdf_internal< enorm< sq_T > >, bdm::mpdf_internal< elognorm >, bdm::mpdf_internal< TEpdf< sq_T > >, bdm::mpdf_internal< egamma >, bdm::mpdf_internal< enorm< ldmat > >, bdm::mpdf_internal< eiWishartCh >, and bdm::mpdf_internal< eigamma >.

References bdm::mpdf::samplecond().

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

- emix.h