User Tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
technical:poisson_spike_train [2021/09/21 09:05] chunchungtechnical:poisson_spike_train [2022/10/10 05:54] chunchung
Line 2: Line 2:
 <code python> <code python>
 def gen_spikes(r,dt): def gen_spikes(r,dt):
-    '''generate spike train from Poisson rate+    '''Generate spike train from Poisson rate
    
     Parameters     Parameters
     ----------     ----------
-    r:  array of spike rates +    r:  Array of spike rates 
-    dt: time step+    dt: Time step
     '''     '''
     i = 0     i = 0
Line 13: Line 13:
     spks = []     spks = []
     while True:     while True:
-        s += -np.log(1-np.random.uniform())+        s += np.random.exponential()
         while s>r[i]*dt:         while s>r[i]*dt:
             s -= r[i]*dt             s -= r[i]*dt
Line 22: Line 22:
             continue             continue
         break         break
-    return spks+    return np.array(spks)
 </code> </code>

This website uses cookies. By using the website, you agree with storing cookies on your computer. Also, you acknowledge that you have read and understand our Privacy Policy. If you do not agree, please leave the website.

More information