Il existe plusieurs threads qui demandent un moyen de simuler des processus poisson non homogènes en temps en python. Le module NeuroTools offre un moyen simple de le faire via la fonction inh_poisson_generator(). L'aide de cette fonction est présentée en bas de ce fil. La fonction a été conçue à l'origine pour simuler des trains de pointes et utilise la méthode d'amincissement. Je voudrais simuler un train de pointes pendant 2000ms. Le taux de pic (en Hertz) change toutes les millisecondes et est compris entre 20 pointes/seconde et 160 pointes/seconde. J'ai essayé de simuler cela en utilisant le code suivant:Simulation d'un processus de Poisson inhomogène dans le temps en utilisant la méthode d'amincissement et le module python de NeuroTools
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)
Cependant, le code renvoie très peu horodatages (par exemple, un tableau ([397,55345905, 1208,79804513, 1478,03525045, 1982,63643262]), qui ne fait pas de sens moi. Je vous serais reconnaissant toute aide à ce sujet.
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