spiketools.sim.train.sim_spiketrain_prob

spiketools.sim.train.sim_spiketrain_prob(p_spiking, n_samples=None, refractory=None)[source]

Simulate spikes based on a probability of spiking per sample.

Parameters:
p_spikingfloat or 1d array

The probability (per sample) of spiking.

n_samplesint, optional

The number of samples to simulate.

refractoryint, optional

The refractory period to apply to the simulated data, in number of samples.

Returns:
spike_train1d array

Simulated spike train.

Raises:
ValueError

If the input variable p_spiking is a float and n_samples is None.

Notes

n_samples is only used if p_spiking is a float. Otherwise n_samples is just the length of p_spiking.

Examples

Simulate a spike train based on a probability of spiking per sample:

>>> p_spiking = 0.3
>>> n_samples = 10
>>> sim_spiketrain = sim_spiketrain_prob(p_spiking, n_samples)

Simulate spike train based on a probability of spiking per sample over time:

>>> p_spiking = np.array([0.3, 0.5, 0.6])
>>> sim_spiketrain = sim_spiketrain_prob(p_spiking)