Defining a white noise process in Python

Short answer is numpy.random.random(). Numpy site description

But since I find more and more answers to similar questions written as numpy.random.normal, I suspect a little description is needed. If I do understand Wikipedia (and a few lessons at the University) correctly, Gauss and White Noise are two separate things. White noise has Uniform distribution, not Normal (Gaussian).

import numpy.random as nprnd
import matplotlib.pyplot as plt

num_samples = 10000
num_bins = 200

samples = numpy.random.random(size=num_samples)

plt.hist(samples, num_bins)
plt.show()

Image: Result

This is my first answer, so if you correct mistakes possibly made by me here, I'll gladly update it. Thanks =)


You can achieve this through the numpy.random.normal function, which draws a given number of samples from a Gaussian distribution.

import numpy
import matplotlib.pyplot as plt

mean = 0
std = 1 
num_samples = 1000
samples = numpy.random.normal(mean, std, size=num_samples)

plt.plot(samples)
plt.show()

1000 random samples drawn from a Gaussian distribution of mean=0, std=1