1 | /*! |
---|
2 | \page userguide_merg BDM Use - Merging of probability distributions |
---|
3 | |
---|
4 | Merging is an operation which combines information from many \c source pdfs into one, the \c merger. |
---|
5 | |
---|
6 | The very basic merger requires that the sources are defined on the same variables. |
---|
7 | |
---|
8 | \section ug_mer_mat Matlab class mexMerger |
---|
9 | |
---|
10 | All mergers in Matlab are derived from a class mexMerger which has only the list of \c sources, their \c weights, the resulting pdf, the \c merger, and operations merge() and validate(). |
---|
11 | |
---|
12 | \code |
---|
13 | classdef mexMerger |
---|
14 | properties |
---|
15 | %> weights of the merged densities |
---|
16 | weights |
---|
17 | %> source pdfs to be merged |
---|
18 | sources |
---|
19 | %> merged density - any pdf understood by epdf_* functions |
---|
20 | merger |
---|
21 | end |
---|
22 | |
---|
23 | methods |
---|
24 | function obj=validate(obj) |
---|
25 | % e.g. check if all sources are compatible |
---|
26 | end |
---|
27 | %> Merge sources into the merger |
---|
28 | function obj=merge(obj) |
---|
29 | % transform old estimate into new estimate |
---|
30 | end |
---|
31 | end |
---|
32 | end |
---|
33 | \endcode |
---|
34 | Validate has the same meaning as in previous chapters, i.e. it is called before any use of the class to check that all elements has been set-up correctly. |
---|
35 | |
---|
36 | Except form that, only few technical functions are needed for integration with C++ classes in BDM, see mexMerger. |
---|
37 | |
---|
38 | mexMErger is an abstract class, which has no operation defined. In order to achieve some functionality an offspring need to be defined. |
---|
39 | An example of one possible offspring is in class mexGaussMergerArit which implements Arithmetic merging of source pdfs which are converted into Gaussians using moment matching. |
---|
40 | |
---|
41 | The offspring only redefines methods validate and merge. |
---|
42 | |
---|
43 | An example how to use this class is in bdmtoolbox/tutorial/merging/merge_mex.m |
---|
44 | \code |
---|
45 | clear all |
---|
46 | pdfs |
---|
47 | |
---|
48 | % merger |
---|
49 | M=mexGaussMergerArit; |
---|
50 | M.weights = [0.5, 0.5]; |
---|
51 | M.sources = {N1a,Ga}; |
---|
52 | M=M.validate(); |
---|
53 | |
---|
54 | M=M.merge(); |
---|
55 | |
---|
56 | figure(1); |
---|
57 | h=epdf_1dplot(N1a); |
---|
58 | set(h,'LineStyle','--'); |
---|
59 | hold on |
---|
60 | h=epdf_1dplot(Ga); |
---|
61 | set(h,'LineStyle','--'); |
---|
62 | |
---|
63 | |
---|
64 | epdf_1dplot(M.merger); |
---|
65 | \endcode |
---|
66 | |
---|
67 | |
---|
68 | For list of all Matlab mergers, see <a href="annotated.html"> list </a>. |
---|
69 | |
---|
70 | \section ug_mer_c Mergers from BDM |
---|
71 | |
---|
72 | More advanced mergers allowing to merge pdfs on partially overlapping variables are available in BDM, specifically, classes bdm::MergerBase and bdm::merger_mix. |
---|
73 | |
---|
74 | Their use is demonstrated in examples: bdmtoolbox/tutorial/merging/merge_grid.m and merge_mix.m, respectively. |
---|
75 | */ |
---|