Want to keep learning?

This content is taken from the Partnership for Advanced Computing in Europe (PRACE)'s online course, Python in High Performance Computing. Join the course to learn more.

Hands-on: Random numbers

In this exercise we practice creating arrays of random numbers.

Source code for this exercise is located in numpy/random-numbers/

Generate a one dimensional 1000 element array of uniformly distributed random numbers using the numpy.random module.

  1. Calculate the mean and standard deviation of the array using numpy.mean() and numpy.std().
  2. Choose some other random distribution and calculate its mean and standard deviation.

You can visualize the random distributions with matplotlib’s hist() function:

import matplotlib.pyplot as plt


Share this article:

This article is from the free online course:

Python in High Performance Computing

Partnership for Advanced Computing in Europe (PRACE)