Changeset 300
- Timestamp:
- 11/06/08 21:26:10 (2 months ago)
- Files:
-
- trunk/doc/stgen.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/doc/stgen.txt
r294 r300 3 3 ==================== 4 4 5 This module offers ways to generate spike trains with certain statistical properties, like poisson-distributed spike trains. It uses the fast and well-tested routines from GNU Scientific Library (gsl) to create random numbers, if they are available. 5 This module offers various stochastic generators for point processes that can 6 be used as spike trains. 6 7 7 8 --------------- … … 16 17 >>> st_gen = StGen() 17 18 18 This will by default try to create a pygsl random generator instance. If Pygsl is not available, numpy will be used. 19 This will initialize the stochastic generator and by default try to create a 20 numpy random generator instance. 19 21 20 Optionally, you can also pass a random number generator instance to the constructor. To use gsl: 22 Optionally, you can also pass a random number generator instance to the 23 constructor: 24 25 >>> import numpy 26 >>> st_gen = StGen(rng = numpy.random.RandomState()) 27 28 You can also use random number generators from gnu scientific library (gsl): 21 29 22 30 >>> from pygsl.rng import rng 23 >>> st_gen_gsl = StGen(gslrng = rng()) 31 >>> st_gen_gsl = StGen(rng = rng()) 32 33 If you want to seed the random number generator with a specific seed, you can 34 do so in the constructor: 35 36 >>> st_gen = StGen(seed = 1234567) 37 38 Alternatively, you can re-seed the random number generator when the StGen 39 object has already been created: 40 41 >>> st_gen.seed(7654321) 24 42 25 Or using numpy:26 43 27 >>> import numpy 28 >>> st_gen_numpy = StGen(numpyrng = numpy.random.RandomState()) 44 Poisson-distributed point processes 45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 29 46 30 Poisson-distributed spike trains 31 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 32 33 Using the ``StGen``-object, you can generate spike trains with inter-spike-intervals distributed according to a poisson distribution: 47 Using the ``StGen``-object, you can generate point processes with 48 inter-spike-intervals distributed according to a poisson distribution: 34 49 35 50 >>> st_gen = StGen() 36 >>> spike_train_poisson = st_gen.poisson_generator(rate = 100., tsim = 2.5) 51 >>> spike_train_poisson = st_gen.poisson_generator(rate = 100., 52 tstart = 0., 53 tstop = 2500.) 37 54 38 This generates an array of spike times with an approximate rate of 100 Hz and a duration of 2.5 seconds. Note that the spike times are in seconds - If spike times should be in ms (as it is a convention in PyNN), rate should be in spikes/ms. 55 This generates a NeuroTools.SpikeTrain object, containing spike times with an 56 approximate rate of 100 Hz and a duration of 2.5 seconds. 39 57 40 Dynamic poisson-distributes spike trains 41 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 58 If you want a numpy array of spike times rather than a SpikeTrain object, 59 specify the array keyword: 42 60 43 StGen can also generate poisson spike trains with dynamically changing rates: 61 >>> spike_train_array = st_gen.poisson_generator(rate = 100., array = True) 62 63 Dynamic poisson-distributes point processes 64 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 65 66 StGen can also generate inhomogeneous poisson processes, i.e. spike trains with 67 dynamically changing rates: 44 68 45 >>> spike_train_dyn = st_gen.poissondyn_generator(tbins = [0., 1., 2.], 46 rate = [50., 80., 30.], 47 tsim = 2.5) 69 >>> spike_train_dyn = st_gen.poissondyn_generator(rate = [50., 80., 30.], 70 t = [0., 1000., 2000.], 71 tstop = 2.5, 72 array = False) 48 73 49 This will generate an array with spike times, with an approximate rate of 50 Hz for one second, followed by 80 Hz for one second, and finally 30 Hz for half a second. 74 This will generate a SpikeTrain object containing spike times with an 75 approximate rate of 50 Hz for one second, followed by 80 Hz for one second, and 76 finally 30 Hz for half a second. Note that t[0] is used as tstart.

