This repository holds the code for the Real Python How to Get Normally Distributed Random Numbers With NumPy tutorial.
The scripts use NumPy, Matplotlib, and SciPy. You should first create a virtual environment:
$ python3 -m venv venv
$ source venv/bin/activateYou can then install the necessary packages with pip:
(venv) $ python -m pip install numpy matplotlib scipyAlternatively, you can install from requirements.txt in order to get the same versions of dependencies that were used when developing and testing the code:
(venv) $ python -m pip install -r requirements.txtUse only one of the pip install commands.
There are four scripts in this repository. The first three—normal_distribution.py, weights.py, and dice.py—show code discussed in the tutorial. The final script, plot_normal_dist.py, contains the code used to generate the first figure in the tutorial.
Each script can be run with python inside your virtual environment:
(venv) $ python normal_distribution.pyYou can run the other scripts with a similar command.
- Geir Arne Hjelle, E-mail: geirarne@realpython.com
Distributed under the MIT license. See LICENSE for more information.