.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/plot_behavior_distribution.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note Click :ref:`here ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_plot_behavior_distribution.py: ========================================= Visualize distribution of velocities ========================================= .. currentmodule:: neural_data_simulator The goal of this example is to show the distribution of velocities used to train the model and compare it with the distribution of the velocities while running the center out reach task. .. GENERATED FROM PYTHON SOURCE LINES 14-17 Set data source ---------------- Retrieve the data from AWS S3 .. GENERATED FROM PYTHON SOURCE LINES 17-32 .. code-block:: default from urllib.parse import urljoin import pooch DOWNLOAD_BASE_URL = "https://neural-data-simulator.s3.amazonaws.com/sample_data/v1/" MONKEY_DATA_PATH = pooch.retrieve( url=urljoin(DOWNLOAD_BASE_URL, "monkey_velocities.npz"), known_hash="md5:b1ef650106210d65da2a3075e7767a21", ) HUMAN_DATA_PATH = pooch.retrieve( url=urljoin(DOWNLOAD_BASE_URL, "human_velocities.npz"), known_hash="md5:b2391f7759845f5256f651dc4e16fb6e", ) .. GENERATED FROM PYTHON SOURCE LINES 33-36 Load data --------- Load the data to be plotted. .. GENERATED FROM PYTHON SOURCE LINES 36-46 .. code-block:: default from matplotlib.pyplot import figure import matplotlib.pyplot as plt import numpy as np monkey_file = np.load(MONKEY_DATA_PATH) human_file = np.load(HUMAN_DATA_PATH) monkey_data = monkey_file["arr_0"] human_data = human_file["data"] .. GENERATED FROM PYTHON SOURCE LINES 47-50 Scale monkey data ------------------ Monkey data has to be scaled in the same way it was done when training the model. .. GENERATED FROM PYTHON SOURCE LINES 50-60 .. code-block:: default from sklearn.preprocessing import StandardScaler VELOCITY_LIMIT = 20 scaler = StandardScaler() scaler.fit(monkey_data) monkey_data = scaler.transform(monkey_data) monkey_data = np.clip(monkey_data, -VELOCITY_LIMIT, VELOCITY_LIMIT) .. GENERATED FROM PYTHON SOURCE LINES 61-63 Plot data ---------- .. GENERATED FROM PYTHON SOURCE LINES 63-80 .. code-block:: default plt.rcParams.update({"font.size": 14}) figure(figsize=(20, 5), dpi=180) plt.hist(human_data[:, 0], color="black", bins=20, label="velocity x", alpha=0.5) plt.hist(human_data[:, 1], color="red", bins=20, label="velocity y", alpha=0.5) plt.legend() plt.title("Human Velocities") plt.show() figure(figsize=(20, 5), dpi=180) plt.hist(monkey_data[:, 0], color="black", bins=20, label="velocity x", alpha=0.5) plt.hist(monkey_data[:, 1], color="red", bins=20, label="velocity y", alpha=0.5) plt.legend() plt.title("Monkey Velocities") plt.show() .. rst-class:: sphx-glr-horizontal * .. image-sg:: /auto_examples/images/sphx_glr_plot_behavior_distribution_001.png :alt: Human Velocities :srcset: /auto_examples/images/sphx_glr_plot_behavior_distribution_001.png :class: sphx-glr-multi-img * .. image-sg:: /auto_examples/images/sphx_glr_plot_behavior_distribution_002.png :alt: Monkey Velocities :srcset: /auto_examples/images/sphx_glr_plot_behavior_distribution_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 1.430 seconds) .. _sphx_glr_download_auto_examples_plot_behavior_distribution.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_behavior_distribution.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_behavior_distribution.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_