Changeset 437 for trunk

Show
Ignore:
Timestamp:
10/01/09 17:29:53 (3 years ago)
Author:
emuller
Message:

Doc string for inh_gamma_generator, and new test

Location:
trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/stgen.py

    r379 r437  
    396396       
    397397    def inh_gamma_generator(self, a, b, t, t_stop, array=False): 
     398        """ 
     399        Returns a SpikeList whose spikes are a realization of an inhomogeneous gamma process  
     400        (dynamic rate). The implementation uses the thinning method, as presented in the  
     401        references. 
     402 
     403        Inputs: 
     404            a,b    - arrays of the parameters of the gamma PDF where a[i] and b[i]  
     405                     will be active on interval [t[i],t[i+1]] 
     406            t      - an array specifying the time bins (in milliseconds) at which to  
     407                     specify the rate 
     408            t_stop - length of time to simulate process (in ms) 
     409            array  - if True, a numpy array of sorted spikes is returned, 
     410                     rather than a SpikeList object. 
     411 
     412        Note:  
     413            t_start=t[0] 
     414            a is a dimensionless quantity > 0, but typically on the order of 2-10.  
     415            a = 1 results in a poisson process. 
     416            b is assumed to be in units of 1/Hz (seconds). 
     417 
     418        References: 
     419 
     420        Eilif Muller, Lars Buesing, Johannes Schemmel, and Karlheinz Meier  
     421        Spike-Frequency Adapting Neural Ensembles: Beyond Mean Adaptation and Renewal Theories 
     422        Neural Comput. 2007 19: 2958-3010. 
     423         
     424        Devroye, L. (1986). Non-uniform random variate generation. New York: Springer-Verlag. 
     425 
     426        Examples: 
     427            See source:trunk/examples/stgen/inh_gamma_psth.py 
     428 
     429        See also: 
     430            inh_poisson_generator, gamma_hazard 
     431        """ 
     432 
    398433        if not self.rpy_checked: 
    399434            self.have_rpy = check_dependency('rpy') 
  • trunk/test/test_stgen.py

    r356 r437  
    187187 
    188188 
     189    def testInhGammaBasic(self): 
     190 
     191        from numpy import array 
     192        import NeuroTools.signals 
     193 
     194        stg = stgen.StGen() 
     195 
     196        st = stg.inh_gamma_generator(array([3.0,3.0]),array([1.0/100.0/3.0,1.0/200.0/3.0]),array([500.0,1500.0]),2500.0,array=True) 
     197 
     198        assert(type(st)==numpy.ndarray) 
     199 
     200        st = stg.inh_gamma_generator(array([3.0,3.0]),array([1.0/100.0/3.0,1.0/200.0/3.0]),array([500.0,1500.0]),2500.0,array=False) 
     201 
     202        assert(type(st)==NeuroTools.signals.spikes.SpikeTrain) 
     203 
     204 
     205 
    189206    def testStatsInhGamma(self): 
    190207 
     
    192209 
    193210        from numpy import array 
     211        import NeuroTools.signals 
    194212 
    195213        stg = stgen.StGen() 
     
    198216 
    199217        st = stg.inh_gamma_generator(array([3.0,3.0]),array([1.0/100.0/3.0,1.0/200.0/3.0]),array([500.0,1500.0]),2500.0,array=True) 
     218 
     219        assert(type(st)==numpy.ndarray) 
    200220 
    201221