0001
0002
0003
0004
0005
0006
0007
0008 close all
0009
0010 addpath(genpath('../General_Functions/'));
0011
0012
0013 NoSample = 3;
0014 N = 300;
0015
0016
0017 d0 = 20;
0018 sigma = 1;
0019
0020
0021 d0l = 10;
0022 sigma_l = 0.5;
0023 d0r = 40;
0024 sigma_r = 3;
0025 dc = 30;
0026
0027
0028
0029
0030
0031 col=['k','b','r','c','m'];
0032 lin=['-','-','-','-','-'];
0033
0034
0035
0036 ss = plot_init;
0037
0038
0039
0040
0041 Sigma=zeros(N);
0042
0043 for n = 1:N
0044 for m = 1:N
0045 d = (n-m)/d0;
0046 Sigma(n,m) = sigma^2*exp(-d^2/2);
0047 end
0048 end
0049
0050
0051 y = rand_gauss(zeros(N,1),Sigma,NoSample);
0052
0053
0054 figure('name','homogeneous GP','color','w','Position',[0.1*ss(1),0.2*ss(2),0.35*ss(1),0.60*ss(2)]); hold on
0055 for s = 1:NoSample
0056 plot(1:N,y(:,s),strcat(lin(s),col(s)),'LineWidth',2);
0057 end
0058 plot(1:N, -3*sigma*ones(1,N),'--k')
0059 plot(1:N, +3*sigma*ones(1,N),'--k')
0060 xlim([-25,N+25])
0061 ylim([-4.5,+4.5]*sigma)
0062 xlabel('$t$');ylabel('$x$')
0063 title('Fig. 2.9: Samples of homogeneous Gaussian Process')
0064
0065
0066
0067
0068
0069 Sigma=zeros(N);
0070
0071 for n=1:N/2
0072 for m=1:N/2
0073 d=(n-m)/d0l;
0074
0075 sig = (sigma_r+(sigma_l-sigma_r)./(1+exp(-(n-N/2)./N.*dc)))*...
0076 (sigma_r+(sigma_l-sigma_r)./(1+exp(-(m-N/2)./N.*dc)));
0077 Sigma(n,m)=sig*exp(-d^2/2);
0078 end
0079 end
0080
0081 for n=N/2+1:N
0082 for m=N/2+1:N
0083 d=(n-m)/d0r;
0084
0085 sig = (sigma_r+(sigma_l-sigma_r)./(1+exp(-(n-N/2)./N.*dc)))*...
0086 (sigma_r+(sigma_l-sigma_r)./(1+exp(-(m-N/2)./N.*dc)));
0087 Sigma(n,m)=sig*exp(-d^2/2);
0088 end
0089 end
0090
0091 for n=1:N/2
0092 for m=N/2+1:N
0093
0094 d=abs(N/2+1/2-n)/d0l + abs(m-N/2-1/2)/d0r;
0095
0096 sig = (sigma_r+(sigma_l-sigma_r)./(1+exp(-(n-N/2)./N.*dc)))*...
0097 (sigma_r+(sigma_l-sigma_r)./(1+exp(-(m-N/2)./N.*dc)));
0098 Sigma(n,m) = sig*exp(-d^2/2);
0099
0100 Sigma(m,n) = Sigma(n,m);
0101 end
0102 end
0103
0104
0105 y = rand_gauss(zeros(N,1),Sigma,NoSample);
0106
0107
0108 rang = N:-1:1;
0109 figure('name','inhomogeneous GP','color','w','Position',[0.55*ss(1),0.2*ss(2),0.35*ss(1),0.60*ss(2)]);hold on
0110
0111 for s = 1:NoSample
0112 plot(1:N,y(rang,s)'+...
0113 3*(sigma_r+...
0114 (sigma_l-sigma_r)./(1+exp(-(rang-N/2)./N*dc))),...
0115 strcat(lin(s),col(s)),'LineWidth',3);
0116 end
0117 xlabel('$x$');ylabel('$z$')
0118 title('Fig. 16.11: Samples of inhomogeneous profiles')