nstat.simulate_cif_from_stimulus
- nstat.simulate_cif_from_stimulus(time, stimulus, beta0, beta1, rng=None)[source]
Simulate a spike train from a log-linear CIF driven by a stimulus.
Computes the conditional intensity
lambda(t) = exp(beta0 + beta1 * x(t))in spikes/second, then draws spikes by independent per-bin Bernoulli sampling (p = 1 - exp(-rate*dt)) at the time-grid resolution implied bytime.- Parameters:
time (ndarray, shape (n_time,)) – Time vector in seconds.
stimulus (ndarray, shape (n_time,)) – Stimulus values at each time sample.
beta0 (float) – Log-baseline rate (intercept of the log-linear CIF).
beta1 (float) – Stimulus coefficient.
rng (np.random.Generator, optional) – Random generator. Defaults to
np.random.default_rng().
- Returns:
spike_train (nspikeTrain) – Simulated spike train.
rate_hz (ndarray, shape (n_time,)) – The instantaneous CIF in spikes per second.
log_rate (ndarray, shape (n_time,)) – The log-rate
beta0 + beta1 * x(t)(useful for diagnostics).
- Return type: