.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/correlospinmatrix_detector_two_neuron.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_correlospinmatrix_detector_two_neuron.py: Correlospinmatrix detector example ---------------------------------- .. only:: html ---- Run this example as a Jupyter notebook: .. card:: :width: 25% :margin: 2 :text-align: center :link: https://lab.ebrains.eu/hub/user-redirect/git-pull?repo=https%3A%2F%2Fgithub.com%2Fnest%2Fnest-simulator-examples&urlpath=lab%2Ftree%2Fnest-simulator-examples%2Fnotebooks%2Fnotebooks%2Fcorrelospinmatrix_detector_two_neuron.ipynb&branch=main :link-alt: JupyterHub service .. image:: https://nest-simulator.org/TryItOnEBRAINS.png .. grid:: 1 1 1 1 :padding: 0 0 2 0 .. grid-item:: :class: sd-text-muted :margin: 0 0 3 0 :padding: 0 0 3 0 :columns: 4 See :ref:`our guide ` for more information and troubleshooting. ---- This scripts simulates two connected binary neurons, similar as in [1]_. It measures and plots the auto- and cross covariance functions of the individual neurons and between them, respectively. References ~~~~~~~~~~ .. [1] Ginzburg and Sompolinsky (1994). Theory of correlations in stochastic neural networks. 50(4) p. 3175. Fig. 1. .. GENERATED FROM PYTHON SOURCE LINES 36-89 .. code-block:: Python import matplotlib.pyplot as plt import nest import numpy as np m_x = 0.5 tau_m = 10.0 h = 0.1 T = 1000000.0 tau_max = 100.0 csd = nest.Create("correlospinmatrix_detector") csd.set(N_channels=2, tau_max=tau_max, Tstart=tau_max, delta_tau=h) n1 = nest.Create("ginzburg_neuron") n1.set(theta=0.0, tau_m=tau_m, c_1=0.0, c_2=2.0 * m_x, c_3=1.0) n2 = nest.Create("mcculloch_pitts_neuron") n2.set(theta=0.5, tau_m=tau_m) nest.Connect(n1, n2, syn_spec={"weight": 1.0}) nest.Connect(n1, csd, syn_spec={"receptor_type": 0}) nest.Connect(n2, csd, syn_spec={"receptor_type": 1}) nest.Simulate(T) count_covariance = csd.count_covariance mean_activities = np.zeros(2, dtype=float) for i in range(2): mean_activities[i] = count_covariance[i][i][int(tau_max / h)] * (h / T) print("mean activities =", mean_activities) covariance_matrix = np.zeros((2, 2, int(2 * tau_max / h) + 1), dtype=float) for i in range(2): for j in range(2): covariance_matrix[i, j] = count_covariance[i][j] * (h / T) - mean_activities[i] * mean_activities[j] ts = np.arange(-tau_max, tau_max + h, h) plt.title("auto- and cross covariance functions") plt.plot(ts, covariance_matrix[0, 1], "r", label=r"$c_{12}$") plt.plot(ts, covariance_matrix[1, 0], "b", label=r"$c_{21}$") plt.plot(ts, covariance_matrix[0, 0], "g", label=r"$c_{11}$") plt.plot(ts, covariance_matrix[1, 1], "y", label=r"$c_{22}$") plt.xlabel(r"time $t \; \mathrm{ms}$") plt.ylabel(r"$c$") plt.legend() plt.show() .. _sphx_glr_download_auto_examples_correlospinmatrix_detector_two_neuron.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: correlospinmatrix_detector_two_neuron.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: correlospinmatrix_detector_two_neuron.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_