Skip to content

Commit

Permalink
Removed sample() function.
Browse files Browse the repository at this point in the history
  • Loading branch information
bnaecker committed Nov 2, 2016
1 parent 209dd0d commit 07421d2
Showing 1 changed file with 1 addition and 37 deletions.
38 changes: 1 addition & 37 deletions pyret/spiketools.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import matplotlib.pyplot as plt

__all__ = ['binspikes', 'estfr', 'sample', 'detectevents', 'peakdet',
__all__ = ['binspikes', 'estfr', 'detectevents', 'peakdet',
'split_trials', 'SpikingEvent']


Expand Down Expand Up @@ -141,42 +141,6 @@ def estfr(tax, bspk, sigma=0.01):
return np.convolve(filt, bspk, mode='full')[size:size + tax.size] / dt


def sample(rate, dt=1.0, num_trials=1):
"""
Sample discrete spikes from a given firing rate
Draws spikes from a Poisson distribution with mean given by `rate`
Parameters
----------
rate : array_like
The time-varying firing rate that is the mean of the Poisson process
dt : float, optional
The bin size of the firing rate, in seconds (Default: 1s)
num_trials : int, optional
The number of trials (repeats) to draw samples for (Default: 1)
Returns
-------
spikes : array_like
An array of shape `num_trials` by `rate.shape` that contains the
sampled number of spikes for each trial in the `rate` array
Notes
-----
Spikes are drawn according to the Poisson distribution:
.. math::
p(n) = (\exp(-r)(r)^n) / n!
"""

return np.random.poisson(rate * dt, (num_trials,) + rate.shape)


class SpikingEvent(object):
"""
The spiking event class bundles together functions that are used to analyze
Expand Down

0 comments on commit 07421d2

Please sign in to comment.