spiketools.sim.train.sim_spiketrain_binom¶
- spiketools.sim.train.sim_spiketrain_binom(p_spiking, n_samples=None, refractory=None)[source]¶
Simulate spike train from a binomial probability distribution.
- 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.7 >>> spike_train = sim_spiketrain_binom(p_spiking, n_samples=5)
Simulate spike train with every sample having its own probability of spiking:
>>> p_spiking = np.array([0, 0.25, 0.5, 0.75, 1]) >>> spike_train = sim_spiketrain_binom(p_spiking, n_samples=5)