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>'; |
---|
8 | f1.mu = 3; |
---|
9 | f1.R = 1; |
---|
10 | f1.rv = a; |
---|
11 | |
---|
12 | f2 = struct('class','enorm<ldmat>',... |
---|
13 | 'mu',-3,... |
---|
14 | 'R', 2,... |
---|
15 | 'rv', a); |
---|
16 | |
---|
17 | |
---|
18 | % merger |
---|
19 | merger.class='merger_mix'; |
---|
20 | merger.method='lognormal'; |
---|
21 | merger.beta=2; |
---|
22 | merger.ncoms=20; |
---|
23 | merger.stop_niter=5; |
---|
24 | merger.effss_coef=1; |
---|
25 | %merger.dbg_file='merger_mix_dbg'; |
---|
26 | |
---|
27 | % support |
---|
28 | support.grid={[-5,5]}; |
---|
29 | support.nbins=[100]; |
---|
30 | |
---|
31 | % 1D |
---|
32 | [vy]=merger_mx({f1,f2},support,merger) |
---|
33 | figure(1) |
---|
34 | hold off |
---|
35 | plot(vy.support,vy.weights,'.') |
---|
36 | hold on |
---|
37 | plot(vy.support,vy.source1,'.r') |
---|
38 | plot(vy.support,vy.source2,'.r') |
---|
39 | |
---|
40 | % wx=vy.weights; |
---|
41 | % [n,x]=hist(wx,15); |
---|
42 | % bar(x,(n.*wx)/sum(n.*wx)); |
---|
43 | |
---|
44 | % 2D sources |
---|
45 | f3 = struct('class','enorm<ldmat>',... |
---|
46 | 'mu',[1,2],... |
---|
47 | 'R', [2 0; 0 1.5],... |
---|
48 | 'rv', ab); |
---|
49 | f4 = struct('class','egiw',... |
---|
50 | 'V',4*[5 2; 2 1],... |
---|
51 | 'nu', 4,... |
---|
52 | 'dimx', 1,... |
---|
53 | 'rv', ab); |
---|
54 | % 2D support |
---|
55 | support2.grid={[-5,5],[0.001,5]}; |
---|
56 | support2.nbins=[20,20]; |
---|
57 | |
---|
58 | % 2D |
---|
59 | vy2=merger_mx({f3,f4},support2,merger) |
---|
60 | X=zeros(support2.nbins(1)); |
---|
61 | Y=zeros(support2.nbins(1)); |
---|
62 | Z=zeros(support2.nbins(1)); |
---|
63 | |
---|
64 | figure(2); |
---|
65 | subplot(1,3,1); |
---|
66 | hold off |
---|
67 | plot(vy2.support(1,:),vy2.support(2,:),'.','MarkerSize',4) |
---|
68 | hold on |
---|
69 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.weights) |
---|
70 | subplot(1,3,2); |
---|
71 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.source1) |
---|
72 | subplot(1,3,3); |
---|
73 | contour_2(vy2.support(1,:),vy2.support(2,:),vy2.source2) |
---|