nemos.glm.GLM.simulate#

GLM.simulate(random_key, feedforward_input)[source]#

Simulate neural activity in response to a feed-forward input.

Parameters:
  • random_key (Array) – jax.random.key for seeding the simulation.

  • feedforward_input (Union[Array, FeaturePytree]) – External input matrix to the model, representing factors like convolved currents, light intensities, etc. When not provided, the simulation is done with coupling-only. Array of shape (n_time_bins, n_basis_input) or pytree of same.

Return type:

Tuple[Array, Array]

Returns:

  • simulated_activity – Simulated activity (spike counts for Poisson GLMs) for the neuron over time. Shape: (n_time_bins, ).

  • firing_rates – Simulated rates for the neuron over time. Shape, (n_time_bins, ).

Raises:
  • NotFittedError

    • If the model hasn’t been fitted prior to calling this method.

  • ValueError

    • If the instance has not been previously fitted.

Examples

>>> # example input
>>> import numpy as np
>>> X, y = np.random.normal(size=(10, 2)), np.random.poisson(size=10)
>>> # define and fit model
>>> import nemos as nmo
>>> model = nmo.glm.GLM()
>>> model = model.fit(X, y)
>>> # generate spikes and rates
>>> random_key = jax.random.key(123)
>>> Xnew = np.random.normal(size=(20, X.shape[1]))
>>> spikes, rates = model.simulate(random_key, Xnew)

See also

nemos.glm.GLM.predict()

Method to predict rates based on the model’s parameters.