有几个线程需要一种方法来模拟python中的时间不均匀泊松过程。 NeuroTools模块通过inh_poisson_generator()函数提供了一种简单的方法。这个函数的帮助是在这个线程的底部介绍的。该功能最初设计用于模拟尖峰火车,并使用减薄方法。 我想在2000ms内模拟一列尖峰火车。峰值速率(以赫兹为单位)每毫秒变化一次,并且包含在20个尖峰/秒和160个尖峰/秒之间。我已经试过这使用下面的代码来模拟:使用细化方法和NeuroTools python模块来模拟时间不均匀的泊松过程
import NeuroTools
import numpy as np
from NeuroTools import stgen
import matplotlib.pyplot as plt
import random
st_gen = stgen.StGen()
time = np.arange(0, 2000)
t_rate = []
for i in range (2000):
t_rate.append(random.randrange(20, 161, 1))
t_rate = np.array(t_rate)
Psim = st_gen.inh_poisson_generator(rate = t_rate, t = time, t_stop = 2000, array = True)
然而,代码返回极少数的时间戳(例如,阵列([397.55345905,1208.79804513,1478.03525045,1982.63643262]),这没有任何意义,以我,我希望得到任何帮助这一点。
inh_poisson_generator(self, rate, t, t_stop, array=False) method of NeuroTools.stgen.StGen instance
Returns a SpikeTrain whose spikes are a realization of an inhomogeneous
poisson process (dynamic rate). The implementation uses the thinning
method, as presented in the references.
Inputs:
rate - an array of the rates (Hz) where rate[i] is active on interval
[t[i],t[i+1]]
t - an array specifying the time bins (in milliseconds) at which to
specify the rate
t_stop - length of time to simulate process (in ms)
array - if True, a numpy array of sorted spikes is returned,
rather than a SpikeList object.
Note:
t_start=t[0]
References:
Eilif Muller, Lars Buesing, Johannes Schemmel, and Karlheinz Meier
Spike-Frequency Adapting Neural Ensembles: Beyond Mean Adaptation and Renewal Theories
Neural Comput. 2007 19: 2958-3010.
Devroye, L. (1986). Non-uniform random variate generation. New York: Springer-Verlag.
Examples:
>> time = arange(0,1000)
>> stgen.inh_poisson_generator(time,sin(time), 1000)enter code here