% Example 2: % Create a renewal process and plot its calculated isi distribution % Also calculate its autocorrelation function. % First define some parameters T=500000; dt=.1; winrad=20; % First define a probability mass function (w) % over a domain (x) % We normalize w to make it a density x=0:.1:11; w=max(0,-(x-6).^2+25); w=w/sum(w); w=w/dt; % Plot this function so that we can compare it to % the isi density subplot(2,2,1); plot(x,w); axis([0 max(x)*1.1 0 max(w)*1.1]) xlabel('x'); ylabel('w'); % Now define the renewal process p=renewal(@()randnum(w,x),T,dt); % Calculate the isi density % Note that instead of specifying the % number of bins for the histogranm we % specify the actual bin cneters (x) [h,t]=isi_density(p,x,dt); % Plot to compare to the (theoretical) density above subplot(2,2,2); plot(t,h); axis([0 max(x)*1.1 0 max(w)*1.1]) xlabel('t') ylabel('isi density') % Calculate the auto-correlation function and plot it % We first delete the delta function spike at the origin subplot(2,1,2) [cc11,x]=cross_corr(p,p,winrad,dt); cc11(winrad/dt+1)=0; bar(x,cc11) xlabel('t') ylabel('autocorrelation') axis([-winrad winrad min(cc11)*1.1 max(cc11)*1.5]) % Calculate the CV ccvv=CV(p,dt)