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