root/trunk/doc/stgen.txt

Revision 300, 2.4 kB (checked in by mschmucker, 2 months ago)

updated stgen docs to reflect eilifs improvements to the API

Line 
1 ====================
2 The ``stgen`` module
3 ====================
4
5 This module offers various stochastic generators for point processes that can
6 be used as spike trains.
7
8 ---------------
9 The StGen class
10 ---------------
11
12 Creation
13 ~~~~~~~~
14
15 Create an ``StGen`` object:
16
17     >>> st_gen = StGen()
18
19 This will initialize the stochastic generator and by default try to create a
20 numpy random generator instance.
21    
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):
29
30     >>> from pygsl.rng import 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)
42    
43
44 Poisson-distributed point processes
45 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
46
47 Using the ``StGen``-object, you can generate point processes with
48 inter-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
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.
57
58 If you want a numpy array of spike times rather than a SpikeTrain object,
59 specify the array keyword:
60
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:
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
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.
Note: See TracBrowser for help on using the browser.