% Fig. 2.9 page 51 and Fig 16.11 page 742 simulate homgeneous/inhomogeneous 1D gaussian process Wolfgang Förstner 2015 last changes: Susanne Wenzel 09/16 wfoerstn@uni-bonn.de, wenzel@igg.uni-bonn.de
0001 %% Fig. 2.9 page 51 and Fig 16.11 page 742 0002 % simulate homgeneous/inhomogeneous 1D gaussian process 0003 % 0004 % Wolfgang Förstner 2015 0005 % last changes: Susanne Wenzel 09/16 0006 % wfoerstn@uni-bonn.de, wenzel@igg.uni-bonn.de 0007 0008 close all 0009 clearvars 0010 0011 addpath(genpath('../General-Functions')); 0012 0013 %% set your parameters ------------------------------------------ 0014 NoSample = 3; % number of smaples for the plot, <5 0015 N = 300; % number of grid points 0016 0017 % parameters for homogeneous gaussian process 0018 d0 = 20; % reference distance 0019 sigma = 1; % standard deviation 0020 0021 % parameters for inhomogeneous gaussian process 0022 d0l = 10; % left reference distance 0023 sigma_l = 0.5; % left std 0024 d0r = 40; % right reference distance 0025 sigma_r = 3; % right standard deviation 0026 dc = 30; % smearing constant 0027 0028 %--------------------------------------------------------------- 0029 0030 %% prepare visualization 0031 % line spec 0032 col=['k','b','r','c','m']; 0033 lin=['-','-','-','-','-']; 0034 0035 % get current screensize, for proper positioning of figures and set default 0036 % plot settings 0037 ss = plot_init; 0038 0039 %% homogeneous GP 0040 0041 % initiate covariance matrix 0042 Sigma=zeros(N); 0043 % generate 300x300 covariance matrix 0044 for n = 1:N 0045 for m = 1:N 0046 d = (n-m)/d0; 0047 Sigma(n,m) = sigma^2*exp(-d^2/2); 0048 end 0049 end 0050 0051 % generate three samples 0052 y = rand_gauss(zeros(N,1),Sigma,NoSample); 0053 0054 % plot samples 0055 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 0056 for s = 1:NoSample 0057 plot(1:N,y(:,s),strcat(lin(s),col(s)),'LineWidth',2); 0058 end 0059 plot(1:N, -3*sigma*ones(1,N),'--k') 0060 plot(1:N, +3*sigma*ones(1,N),'--k') 0061 xlim([-25,N+25]) 0062 ylim([-4.5,+4.5]*sigma) 0063 xlabel('$t$');ylabel('$x$') 0064 title('Fig. 2.9: Samples of homogeneous Gaussian Process') 0065 0066