We can detect white noise by using the following tools:
- Line plot: Once we have a line plot, we can have an idea of whether the series has a constant mean and variance
- Autocorrelation plot: Having a correlation plot can give us an inkling as to whether there is an association among lagged variables
- Summary: Checking the mean and variance of the series against the mean and variance of meaningful contiguous blocks of values in the series
Let's do this in Python:
- First, we will import all the required libraries as follows:
from random import gauss
from random import seed
from pandas import Series
from pandas.tools.plotting import autocorrelation_plot
from matplotlib import pyplot
- Next, we will set up the white noise series for us to analyze, as follows:
seed(1000)
#creating white noise series
series = [gauss(0.0, 1.0) for i in range(500)]
series = Series(series)
- Let's take the summary or statistic of it using the following code:
print(series.describe())
We will get the following output:
Here, we can see that the mean is approaching zero and the standard deviation is close to 1.
- Let's make a line plot now to check out the trend, using the following code:
series.plot()
pyplot.show()
We will get the following output:
The line plot looks totally random, and no trend can be observed here.
- It's time to make an autocorrelation plot. Let's set one up using the following code:
autocorrelation_plot(series)
pyplot.show()
We will get the following output:
Even in an autocorrelation function plot, the correlation breaches the band of our confidence level. This tells us that it is a white noise series.