spiketools.stats.shuffle.shuffle_poisson

spiketools.stats.shuffle.shuffle_poisson(spikes, n_shuffles=1000, start_time=0)[source]

Shuffle spikes based on generating new spike trains from a Poisson distribution.

Parameters:
spikes1d array

Spike times, in seconds.

n_shufflesint, optional, default: 1000

The number of shuffles to create.

start_timefloat, optional

The start time of the input spikes, used to set the time values of the shuffled outputs.

Returns:
shuffled_spikeslist of 1d array

Shuffled spike times.

Notes

This approach creates “shuffles” by simulating new spike trains from a Poisson distribution.

Note that this approach is therefore not strictly a “shuffle” in the sense that the outputs are not literally ‘shuffled’ versions of the input, and are instead new / simulated set of spikes sampled based on the statistics of the input.

In addition, since this approach simulates new spike trains based on an average rate, different iterations of the shuffles are not guaranteed to have the same number of spikes (and are not guaranteed to have the same number of spikes as the input). This is why the outputs are returned are a list of shuffles.

Examples

Shuffle spike times using the Poisson method:

>>> from spiketools.sim.times import sim_spiketimes
>>> spikes = sim_spiketimes(5, 30, 'poisson')
>>> shuffled_spikes = shuffle_poisson(spikes, n_shuffles=5)