Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revisionLast revisionBoth sides next revision | ||
technical:poisson_spike_train [2021/09/21 09:05] – chunchung | technical:poisson_spike_train [2022/10/10 05:54] – chunchung | ||
---|---|---|---|
Line 2: | Line 2: | ||
<code python> | <code python> | ||
def gen_spikes(r, | def gen_spikes(r, | ||
- | ''' | + | ''' |
Parameters | Parameters | ||
---------- | ---------- | ||
- | r: | + | r: |
- | 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> | while s> | ||
s -= r[i]*dt | s -= r[i]*dt | ||
Line 22: | Line 22: | ||
continue | continue | ||
break | break | ||
- | return spks | + | return |
</ | </ |