root/trunk/doc/stgen.txt

Revision 300, 2.4 KB (checked in by mschmucker, 4 years ago)

updated stgen docs to reflect eilifs improvements to the API

Line 
1====================
2The ``stgen`` module
3====================
4
5This module offers various stochastic generators for point processes that can
6be used as spike trains.
7
8---------------
9The StGen class
10---------------
11
12Creation
13~~~~~~~~
14
15Create an ``StGen`` object:
16
17    >>> st_gen = StGen()
18
19This will initialize the stochastic generator and by default try to create a
20numpy random generator instance.
21   
22Optionally, you can also pass a random number generator instance to the
23constructor:
24
25    >>> import numpy
26    >>> st_gen = StGen(rng = numpy.random.RandomState())
27
28You can also use random number generators from gnu scientific library (gsl):
29
30    >>> from pygsl.rng import rng
31    >>> st_gen_gsl = StGen(rng = rng())
32
33If you want to seed the random number generator with a specific seed, you can
34do so in the constructor:
35
36    >>> st_gen = StGen(seed = 1234567)
37
38Alternatively, you can re-seed the random number generator when the StGen
39object has already been created:
40
41    >>> st_gen.seed(7654321)
42   
43
44Poisson-distributed point processes
45~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
47Using the ``StGen``-object, you can generate point processes with
48inter-spike-intervals distributed according to a poisson distribution:
49
50    >>> st_gen = StGen()
51    >>> spike_train_poisson = st_gen.poisson_generator(rate = 100.,
52                                                       tstart = 0.,
53                                                       tstop = 2500.)
54
55This generates a NeuroTools.SpikeTrain object, containing spike times with an
56approximate rate of 100 Hz and a duration of 2.5 seconds.
57
58If you want a numpy array of spike times rather than a SpikeTrain object,
59specify the array keyword:
60
61    >>> spike_train_array = st_gen.poisson_generator(rate = 100., array = True)
62
63Dynamic poisson-distributes point processes
64~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
65
66StGen can also generate inhomogeneous poisson processes, i.e. spike trains with
67dynamically changing rates:
68   
69    >>> spike_train_dyn = st_gen.poissondyn_generator(rate = [50., 80., 30.],
70                                                      t = [0., 1000., 2000.],
71                                                      tstop = 2.5,
72                                                      array = False)
73
74This will generate a SpikeTrain object containing spike times with an
75approximate rate of 50 Hz for one second, followed by 80 Hz for one second, and
76finally 30 Hz for half a second. Note that t[0] is used as tstart.
Note: See TracBrowser for help on using the browser.