Search code examples
pythonnumpyscipyprobabilitynoise

Defining a white noise process in Python


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.)?


Solution

  • 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