This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/pointprocesses/exercises/hompoissonspikes.m
2014-11-12 18:39:02 +01:00

20 lines
557 B
Matlab

function spikes = hompoissonspikes( trials, rate, tmax )
% Generate spike times of a homogeneous poisson process
% trials: number of trials that should be generated
% rate: the rate of the Poisson process in Hertz
% tmax: the duration of each trial in seconds
% returns a cell array of vectors of spike times
dt = 3.33e-5;
p = rate*dt;
if p > 0.2
p = 0.2
dt = p/rate;
end
x = rand( trials, ceil(tmax/dt) );
spikes = cell( trials, 1 );
for k=1:trials
spikes{k} = find( x(k,:) >= 1.0-p ) * dt;
end
end