User Tools

This is an old revision of the document!


Inhomogeneous Poisson spike train generation

def gen_spikes(r,dt):
    '''generate spike train from Poisson rate
 
    Parameters
    ----------
    r:  array of spike rates
    dt: time step
    '''
    i = 0
    s = 0
    spks = []
    while True:
        s += -np.log(1-np.random.uniform())
        while s>r[i]*dt:
            s -= r[i]*dt
            i += 1
            if i>=len(r): break
        else:
            spks.append(i*dt+s/r[i])
            continue
        break
    return spks

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