From: JUN on
bonjour

I am trying to generate correlated spike trains, which consists in selecting spikes from common spikes trains. I start with the case of a homogeneous pool with instantaneous correlations, I simulated two homogeneous Poisson spike trains and the input correlation between two spikes trains , the source code is

clear

dt =0.0001;
tmax = 3;
t = 0:dt:tmax;


Ntrials = 2; %the number of trails

spikes = zeros(Ntrials,length(t));
r=zeros(Ntrials,length(t));



for i = 1:length(t)
r(i)=5;
if dt*r(i)>rand(1) % using a Poisson spike generator
spikes1(i) = 1.0; % include a spike if the rate is high enough
end

end


for i = 1:length(t)
r(i)=5;
if dt*r(i)>rand(1) % using a Poisson spike generator
spikes2(i) = 1.0; % include a spike if the rate is high enough
end

end
figure(1)

subplot(2,1,1),plot(spikes1);
subplot(2,1,2),plot(spikes2);

c= cov(spikes1, spikes2)/sqrt(var(spikes1)*var( spikes2)) % input correlations

my questions are:

the lengths of spikes1 and spkies2 don't match.how I can do ?

how to generate the spikes input are selected from two homogeneous
Poisson spike trains each of rate r such that the with-in group correlation strength is 0 ≤ c ≤ 1 ?

Could you please help me ?

Thanks.
merci mille fois