function [t_vect, spk_vect] = inhom_pp(rate) %this function simulates an inhomogeneous Poisson %process of constant rate by the integrate method %described in the lecture notes %It returns a time vector and a spike vector dt = 0.05; t_vect = 0:dt:1000; v_vect = zeros(size(t_vect)); spk_vect = zeros(size(t_vect)); v_thres = exprnd(1); v(1) = 0; rho = rate/1000; %in spk/msec for i = 2:length(t_vect) v(i) = v(i-1) + dt*rho; if (v(i) > v_thres) v(i) = 0; spk_vect(i) = 1; v_thres = exprnd(1); end; end;