Home > 16-Surface-Reconstruction > Profile-Reconstruction > fig_16_11_simulate_inhom_profiles_gaussian.m

fig_16_11_simulate_inhom_profiles_gaussian

PURPOSE ^

% Fig. 16.11 on p. 742

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

% Fig. 16.11 on p. 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

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 %% Fig. 16.11 on p. 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 
0040 %% inhomogeneous GP
0041 
0042 % initiate covariance matrix
0043 Sigma=zeros(N);  
0044 % generate left upper covariance matrix
0045 for n=1:N/2
0046     for m=1:N/2
0047         d=(n-m)/d0l;
0048         % smear sigma using sigmoid function
0049         sig = (sigma_r+(sigma_l-sigma_r)./(1+exp(-(n-N/2)./N.*dc)))*...
0050               (sigma_r+(sigma_l-sigma_r)./(1+exp(-(m-N/2)./N.*dc)));
0051         Sigma(n,m)=sig*exp(-d^2/2);
0052     end
0053 end
0054 % generate right lower covariance matrix
0055 for n=N/2+1:N
0056     for m=N/2+1:N
0057         d=(n-m)/d0r;
0058         % smear sigma using sigmoid function
0059         sig = (sigma_r+(sigma_l-sigma_r)./(1+exp(-(n-N/2)./N.*dc)))*...
0060               (sigma_r+(sigma_l-sigma_r)./(1+exp(-(m-N/2)./N.*dc)));
0061         Sigma(n,m)=sig*exp(-d^2/2);
0062     end
0063 end
0064 % generate  right upper covariance matrix
0065 for n=1:N/2
0066     for m=N/2+1:N
0067         % take mean distance
0068         d=abs(N/2+1/2-n)/d0l + abs(m-N/2-1/2)/d0r;
0069         % smear sigma using sigmoid function
0070         sig = (sigma_r+(sigma_l-sigma_r)./(1+exp(-(n-N/2)./N.*dc)))*...
0071               (sigma_r+(sigma_l-sigma_r)./(1+exp(-(m-N/2)./N.*dc)));
0072         Sigma(n,m) = sig*exp(-d^2/2);
0073         % fill symmetric part
0074         Sigma(m,n) = Sigma(n,m);
0075     end
0076 end
0077 
0078 % generate samples
0079 y = rand_gauss(zeros(N,1),Sigma,NoSample);
0080 
0081 % prepare plot
0082 rang = N:-1:1;
0083 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
0084 % plot samples: y + 3*sigma(smeared)
0085 for s = 1:NoSample
0086     plot(1:N,y(rang,s)'+...
0087         3*(sigma_r+...
0088         (sigma_l-sigma_r)./(1+exp(-(rang-N/2)./N*dc))),...
0089         strcat(lin(s),col(s)),'LineWidth',3);
0090 end
0091 xlabel('$x$');ylabel('$z$')
0092 title('Fig. 16.11: Samples of inhomogeneous profiles')

Generated on Sat 21-Jul-2018 20:56:10 by m2html © 2005