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