The following example simulates spiking activity in a sparse random network with recurrent excitation and inhibition
The figure shows the spiking activity of 50 neurons as a raster plot.
Time increases along the horizontal axis, neuron id increases along the vertical axis.
 Each dot corresponds to a spike of the respective neuron at a given time.
The lower part of the figure shows a histogram with the mean firing-rate of the neurons.

import nestimport nest.raster_plotJ_ex  = 0.1 # excitatory weightJ_in  = -0.5 # inhibitory weightp_rate = 20000. #
external Poisson rateneuron_params= {"C_m": 1.0, "tau_m": 20.0, "t_ref": 2.0,
                "E_L": 0.0, "V_reset": 0.0, "V_m": 0.0, "V_th": 20.0}# Set parameters of neurons and devicesnest.
SetDefaults("iaf_psc_delta", neuron_params)nest.
SetDefaults("poisson_generator", {"rate": p_rate})nest.
SetDefaults("spike_detector", {"withtime": True, "withgid": True})# Create neurons and devicesnodes_ex=nest.
Create("iaf_psc_delta", 10000) 
nodes_in=nest.
Create("iaf_psc_delta", 2500)noise=nest.
Create("poisson_generator")espikes=nest.
Create("spike_detector")# Configure synapse modelsnest.
CopyModel("static_synapse", "excitatory", {"weight":J_ex, "delay":1.5})nest.
CopyModel("static_synapse", "inhibitory", {"weight":J_in, "delay":1.5})# Connect the random net and instrument it with the devicesnest.
Connect(nodes_ex, nodes_ex+nodes_in, {"rule": 'fixed_indegree', "indegree": 1000}, "excitatory")nest.
Connect(nodes_in, nodes_ex+nodes_in, {"rule": 'fixed_indegree', "indegree": 250}, "inhibitory")nest.
Connect(noise, nodes_ex+nodes_in, syn_spec="excitatory")nest.
Connect(nodes_ex[1:51], espikes)# Simulate for 100.
msnest.
Simulate(100.)#
Plot resultsnest.raster_plot.from_device(espikes, hist=True)nest.raster_plot.show()
The following example simulates spiking activity in a sparse random network with recurrent excitation and inhibition
The figure shows the spiking activity of 50 neurons as a raster plot. Time increases along the horizontal axis, neuron id increases along the vertical axis.  Each dot corresponds to a spike of the respective neuron at a given time. The lower part of the figure shows a histogram with the mean firing-rate of the neurons.
import nestimport nest.raster_plotJ_ex  = 0.1 # excitatory weightJ_in  = -0.5 # inhibitory weightp_rate = 20000. # external Poisson rateneuron_params= {"C_m": 1.0, "tau_m": 20.0, "t_ref": 2.0,
                "E_L": 0.0, "V_reset": 0.0, "V_m": 0.0, "V_th": 20.0}# Set parameters of neurons and devicesnest.SetDefaults("iaf_psc_delta", neuron_params)nest.SetDefaults("poisson_generator", {"rate": p_rate})nest.SetDefaults("spike_detector", {"withtime": True, "withgid": True})# Create neurons and devicesnodes_ex=nest.Create("iaf_psc_delta", 10000) 
nodes_in=nest.Create("iaf_psc_delta", 2500)noise=nest.Create("poisson_generator")espikes=nest.Create("spike_detector")# Configure synapse modelsnest.CopyModel("static_synapse", "excitatory", {"weight":J_ex, "delay":1.5})nest.CopyModel("static_synapse", "inhibitory", {"weight":J_in, "delay":1.5})# Connect the random net and instrument it with the devicesnest.Connect(nodes_ex, nodes_ex+nodes_in, {"rule": 'fixed_indegree', "indegree": 1000}, "excitatory")nest.Connect(nodes_in, nodes_ex+nodes_in, {"rule": 'fixed_indegree', "indegree": 250}, "inhibitory")nest.Connect(noise, nodes_ex+nodes_in, syn_spec="excitatory")nest.Connect(nodes_ex[1:51], espikes)# Simulate for 100. msnest.Simulate(100.)# Plot resultsnest.raster_plot.from_device(espikes, hist=True)nest.raster_plot.show()
NEST (software)