[1040] | 1 | %> @file mexEpdf.m |
---|
| 2 | %> @brief File mappring root class of epdf from BDM |
---|
| 3 | % ====================================================================== |
---|
| 4 | %> @brief Abstract class of unconditional probability density function (epdf) |
---|
| 5 | % |
---|
| 6 | %> This class provides a bridge between bdm::epdf and Matlab |
---|
| 7 | % ====================================================================== |
---|
[937] | 8 | classdef mexEpdf |
---|
| 9 | properties |
---|
[1040] | 10 | %> Description of random variable (see definitiopn of RV) |
---|
| 11 | rv=RV; |
---|
[937] | 12 | end |
---|
| 13 | methods |
---|
[1040] | 14 | %> Function returning mean value of this epdf |
---|
[937] | 15 | function m=mean(p) |
---|
| 16 | error('define how to compute mean') |
---|
| 17 | end |
---|
[1040] | 18 | %> This function is called before using the object. It should check consistency of the properties and fill default values. |
---|
[937] | 19 | function validate(p) |
---|
| 20 | error('check if the density is consistent') |
---|
| 21 | end |
---|
[1040] | 22 | %> Tell the world around it dimension of the random variable |
---|
[937] | 23 | function dim=dimension(p) |
---|
| 24 | error('return dimension of the density') |
---|
| 25 | end |
---|
[1040] | 26 | %> Function returning variance of this epdf |
---|
[937] | 27 | function v=variance(p) |
---|
| 28 | error('define how to compute mean') |
---|
| 29 | end |
---|
[1040] | 30 | %> Function returning logarithm of likelihood function in point x |
---|
[937] | 31 | function l=evallog(p,x) |
---|
| 32 | error('define how to evaluate log of this density at point x') |
---|
| 33 | end |
---|
[1040] | 34 | %> Function returning a signle sample from this density |
---|
[1037] | 35 | function l=sample(p) |
---|
| 36 | error('define how to sample from this density') |
---|
| 37 | end |
---|
[943] | 38 | |
---|
[944] | 39 | %%% default functions -- no need to redefine %%% |
---|
[943] | 40 | |
---|
[1040] | 41 | %> Function returning logarithm of NON-normalized likelihood function in point x (speed optimization) |
---|
[937] | 42 | function l=evallog_nn(p,x) |
---|
| 43 | % define how to evaluate non-normalized log of this density at point x |
---|
| 44 | % makes sense if faster than normalized |
---|
[1037] | 45 | l=evallog(p,x); |
---|
[937] | 46 | end |
---|
[1040] | 47 | |
---|
[943] | 48 | function r=get_rv(p) |
---|
| 49 | r=p.rv; |
---|
| 50 | end |
---|
[1040] | 51 | %> Function returning a matrix of n samples from this density, |
---|
[1037] | 52 | function m = samplemat(obj, n) |
---|
| 53 | m = zeros(obj.dimension, n); |
---|
| 54 | for i=1:n |
---|
| 55 | m(:,i) = obj.sample; |
---|
| 56 | end |
---|
| 57 | end |
---|
[937] | 58 | end |
---|
| 59 | end |
---|