| 1 | % Random Variables | 
|---|
| 2 | a=RV({'a'}); | 
|---|
| 3 | b=RV({'b'}); | 
|---|
| 4 | ab=RVjoin([a,b]); | 
|---|
| 5 |  | 
|---|
| 6 | % Sources | 
|---|
| 7 | f1.class= 'enorm<ldmat>'; | 
|---|
| 8 | f1.mu   = 5; | 
|---|
| 9 | f1.R    = 1; | 
|---|
| 10 | f1.rv   = b; | 
|---|
| 11 |  | 
|---|
| 12 | % merger | 
|---|
| 13 | Merger.class='merger_mix'; | 
|---|
| 14 | Merger.method='lognormal'; | 
|---|
| 15 | Merger.beta=1.2; | 
|---|
| 16 | Merger.ncoms=20; | 
|---|
| 17 | Merger.stop_niter=50; | 
|---|
| 18 | Merger.effss_coef=0.9; | 
|---|
| 19 | %Merger.dbg_file='merger_mix_dbg'; | 
|---|
| 20 |  | 
|---|
| 21 |  | 
|---|
| 22 | % 2D sources | 
|---|
| 23 | f3 = struct('class','enorm<ldmat>',... | 
|---|
| 24 | 'mu',[1,2],... | 
|---|
| 25 | 'R',  [1 -0.5; -0.5 1],... | 
|---|
| 26 | 'rv', ab); | 
|---|
| 27 | f4 = struct('class','mlnorm<ldmat>',... | 
|---|
| 28 | 'rv',a,... | 
|---|
| 29 | 'rvc', b,... | 
|---|
| 30 | 'A',  1,... | 
|---|
| 31 | 'const', 0,... | 
|---|
| 32 | 'R',1); | 
|---|
| 33 | % 2D support | 
|---|
| 34 | support2.class='rectangular_support'; | 
|---|
| 35 | support2.ranges={[-5,5],[0.001,9]}; | 
|---|
| 36 | support2.gridsizes=[30,30]; | 
|---|
| 37 |  | 
|---|
| 38 | % 2D | 
|---|
| 39 | %vy2=merger({f3,f1}, support2, Merger) | 
|---|
| 40 | vy2=merger({f3,f4}, support2, Merger) | 
|---|
| 41 |  | 
|---|
| 42 | figure(2); | 
|---|
| 43 | subplot(2,2,1); | 
|---|
| 44 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.source1) | 
|---|
| 45 | % set(gca,'XLim',[-5,5]) | 
|---|
| 46 | % set(gca,'YLim',[-1,7]) | 
|---|
| 47 | title('Source 1') | 
|---|
| 48 | subplot(2,2,2); | 
|---|
| 49 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.source2') | 
|---|
| 50 | % set(gca,'XLim',[-5,5]) | 
|---|
| 51 | % set(gca,'YLim',[-1,7]) | 
|---|
| 52 | title('Source 2') | 
|---|
| 53 |  | 
|---|
| 54 | subplot(2,2,3); | 
|---|
| 55 | hold off | 
|---|
| 56 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.mix) | 
|---|
| 57 | % set(gca,'XLim',[-5,5]) | 
|---|
| 58 | % set(gca,'YLim',[-1,7]) | 
|---|
| 59 | title('Mixture Approximation') | 
|---|
| 60 |  | 
|---|
| 61 | subplot(2,2,4); | 
|---|
| 62 | hold off | 
|---|
| 63 | plot(vy2.support(1,:),vy2.support(2,:),'.','MarkerSize',4) | 
|---|
| 64 | hold on | 
|---|
| 65 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.weights) | 
|---|
| 66 | % set(gca,'XLim',[-5,5]) | 
|---|
| 67 | % set(gca,'YLim',[-1,7]) | 
|---|
| 68 | title('Weighted Empirical') | 
|---|
| 69 |  | 
|---|