Defining a white noise process in Python

dbliss picture dbliss · Aug 27, 2015 · Viewed 36k times · Source

I need to draw samples from a white noise process in order to implement a particular integral numerically.

How do I generate this with Python (i.e., numpy, scipy, etc.)?

Answer

Sam picture Sam · Aug 27, 2015

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