root/applications/bdmtoolbox/tutorial/merging/merge_grid.m @ 531

Revision 409, 1.8 kB (checked in by smidl, 15 years ago)

tutorial for merging in bdmtoolbox

Line 
1pdfs; % load example pdfs
2
3f1=N1a;
4f2=N2a;
5f3=Ga;
6
7% merger
8Merger.class='merger_base';
9Merger.beta=1;
10
11% support
12support.grid={[-5,5]};
13support.nbins=[100];
14
15% 1D
16Merger.method='arithmetic';
17[vy]=merger({f1,f2},support,Merger)
18    figure(1)
19    subplot(1,3,1);
20    hold off
21    plot(vy.support,vy.weights,'-')
22    hold on
23    plot(vy.support,vy.source1,'--')
24    plot(vy.support,vy.source2,'--')
25
26Merger.method='lognormal';
27[vy]=merger({f1,f3},support,Merger)
28    subplot(1,3,2);
29    hold off
30    plot(vy.support,vy.weights,'-')
31    hold on
32    plot(vy.support,vy.source1,'--')
33    plot(vy.support,vy.source2,'--')
34
35Merger.method='geometric';
36[vy]=merger({f1,f2},support,Merger)
37    subplot(1,3,3);
38    hold off
39    plot(vy.support,vy.weights,'-')
40    hold on
41    plot(vy.support,vy.source1,'--')
42    plot(vy.support,vy.source2,'--')
43
44%%
45f3=Nab;
46f4=GiW;
47
48% 2D support
49type=0;
50if type==0
51    support2.grid={[-5,5],[0.001,5]};
52    support2.nbins=[10,10];
53else
54    support2=struct('pdf',...
55            struct('class','enorm<ldmat>','mu',[1,2],'R',[2 0; 0 2]));
56    support2.nsamples=[100];
57end   
58
59% 2D
60vy2=merger({f3,f4},support2,Merger)
61
62if type==0
63    X=zeros(support2.nbins(1));
64    Y=zeros(support2.nbins(1));
65    Z=zeros(support2.nbins(1));
66
67    X(:)=vy2.support(1,:);
68    Y(:)=vy2.support(2,:);
69    Z(:)=vy2.weights(:);
70   
71    figure(2);
72    subplot(1,3,1);
73    contour(X,Y,Z);
74    subplot(1,3,2);
75    Z(:)=vy2.source1(:);
76    contour(X,Y,Z,'--');
77    subplot(1,3,3);
78    Z(:)=vy2.source2(:);
79    contour(X,Y,Z,'--');
80else
81    figure(2);
82    subplot(1,3,1);
83    hold off
84    plot(vy2.support(1,:),vy2.support(2,:),'.','MarkerSize',4)
85    hold on
86    contour_2(vy2.support(1,:),vy2.support(2,:),vy2.weights)
87    subplot(1,3,2);
88    contour_2(vy2.support(1,:),vy2.support(2,:),vy2.source1)
89    subplot(1,3,3);
90    contour_2(vy2.support(1,:),vy2.support(2,:),vy2.source2)
91end
Note: See TracBrowser for help on using the browser.