# White Noise Time Series with Python

Last Updated on

White noise is an important concept in time series forecasting.

If a time series is white noise, it is a sequence of random numbers and cannot be predicted. If the series of forecast errors are not white noise, it suggests improvements could be made to the predictive model.

In this tutorial, you will discover white noise time series with Python.

After completing this tutorial, you will know:

• The definition of a white noise time series and why it matters.
• How to check if your time series is white noise.
• Statistics and diagnostic plots to identify white noise in Python.

Discover how to prepare and visualize time series data and develop autoregressive forecasting models in my new book, with 28 step-by-step tutorials, and full python code.

Let’s get started.

• Updated Sept/2019: Updated examples to use latest API.
• Updated Oct/2019: Made the check for white noise clearer (thanks Samuel Corradi) White Noise Time Series with Python
Photo by Dan Eckert, some rights reserved.

## What is a White Noise Time Series?

A time series may be white noise.

A time series is white noise if the variables are independent and identically distributed with a mean of zero.

This means that all variables have the same variance (sigma^2) and each value has a zero correlation with all other values in the series.

If the variables in the series are drawn from a Gaussian distribution, the series is called Gaussian white noise.

## Why Does it Matter?

White noise is an important concept in time series analysis and forecasting.

It is important for two main reasons:

1. Predictability: If your time series is white noise, then, by definition, it is random. You cannot reasonably model it and make predictions.
2. Model Diagnostics: The series of errors from a time series forecast model should ideally be white noise.

Model Diagnostics is an important area of time series forecasting.

Time series data are expected to contain some white noise component on top of the signal generated by the underlying process.

For example:

Once predictions have been made by a time series forecast model, they can be collected and analyzed. The series of forecast errors should ideally be white noise.

When forecast errors are white noise, it means that all of the signal information in the time series has been harnessed by the model in order to make predictions. All that is left is the random fluctuations that cannot be modeled.

A sign that model predictions are not white noise is an indication that further improvements to the forecast model may be possible.

### Stop learning Time Series Forecasting the slow way!

Take my free 7-day email course and discover how to get started (with sample code).

Click to sign-up and also get a free PDF Ebook version of the course.

## Is your Time Series White Noise?

Your time series is probably NOT white noise if one or more of the following conditions are true:

• Is the mean/level non-zero?
• Does the mean/level change over time?
• Does the variance change over time?
• Do values correlate with lag values?

Some tools that you can use to check if your time series is white noise are:

• Create a line plot. Check for gross features like a changing mean, variance, or obvious relationship between lagged variables.
• Calculate summary statistics. Check the mean and variance of the whole series against the mean and variance of meaningful contiguous blocks of values in the series (e.g. days, months, or years).
• Create an autocorrelation plot. Check for gross correlation between lagged variables.

## Example of White Noise Time Series

In this section, we will create a Gaussian white noise series in Python and perform some checks.

It is helpful to create and review a white noise time series in practice. It will provide the frame of reference and example plots and statistical tests to use and compare on your own time series projects to check if they are white noise.

Firstly, we can create a list of 1,000 random Gaussian variables using the gauss() function from the random module.

We will draw variables from a Gaussian distribution with a mean (mu) of 0.0 and a standard deviation (sigma) of 1.0.

Once created, we can wrap the list in a Pandas Series for convenience.

Next, we can calculate and print some summary statistics, including the mean and standard deviation of the series.

Given that we defined the mean and standard deviation when drawing the random numbers, there should be no surprises.

We can see that the mean is nearly 0.0 and the standard deviation is nearly 1.0. Some variance is expected given the small size of the sample.

If we had more data, it might be more interesting to split the series in half and calculate and compare the summary statistics for each half. We would expect to see a similar mean and standard deviation for each sub-series.

Now we can create some plots, starting with a line plot of the series.

We can see that it does appear that the series is random. White Noise Series Line Plot

We can also create a histogram and confirm the distribution is Gaussian.

Indeed, the histogram shows the tell-tale bell-curve shape. White Noise Series Histogram Plot

Finally, we can create a correlogram and check for any autocorrelation with lag variables.

The correlogram does not show any obvious autocorrelation pattern.

There are some spikes above the 95% and 99% confidence level, but these are a statistical fluke. White Noise Series Correlogram Plot

For completeness, the complete code listing is provided below.

This section lists some resources for further reading on white noise and white noise time series.

## Summary

In this tutorial, you discovered white noise time series in Python.

Specifically, you learned:

• White noise time series is defined by a zero mean, constant variance, and zero correlation.
• If your time series is white noise, it cannot be predicted, and if your forecast residuals are not white noise, you may be able to improve your model.
• The statistics and diagnostic plots you can use on your time series to check if it is white noise.

## Want to Develop Time Series Forecasts with Python? #### Develop Your Own Forecasts in Minutes

...with just a few lines of python code

Discover how in my new Ebook:
Introduction to Time Series Forecasting With Python

It covers self-study tutorials and end-to-end projects on topics like: Loading data, visualization, modeling, algorithm tuning, and much more...

### 18 Responses to White Noise Time Series with Python

1. Mak July 14, 2017 at 7:57 pm #

Do I need to remove the trend of data before we check for white noise ? Thanks

• Jason Brownlee July 15, 2017 at 9:42 am #

Yes, great question!

2. Narendra July 18, 2018 at 10:38 pm #

zero mean is the requirement of white noise series.But the above article says the opposite.Please clarify.

• Jason Brownlee July 19, 2018 at 7:53 am #

I mention that white noise has a zero mean in the article.

3. Jagadish November 17, 2018 at 11:22 pm #

Hello,

I have a doubt on how do we calculate the error term in the moving average model,. in most of the sites it was mentioned that it is the difference between the yactual-yhat , however If i am trying to use the error term to find the yhat , how do I have the value of yhat, until I predict it.

Please give reference on how to calculate the error term in Moving average time series.

4. rookie December 10, 2018 at 7:05 pm #

Hello! In the section of “Is your Time Series White Noise?”,you list three question for us to check if our series is White Noise and the first question is “Does your series have a zero mean?”.According to the meaning of this part, if our data mean is 0, then it is not white noise.I think there is some contradiction here because you mention that the mean value of White Noise is 0 as well.

• Jason Brownlee December 11, 2018 at 7:41 am #

Sorry, I don’t follow. Can you please elaborate?

5. Momo March 31, 2019 at 3:47 am #

Hello,

I’m working on a project, I have an Event log and I want to know if it’s possible to find out if it’s white noise or no. So I want to know if process activities are predictable or no. If yes, how can I do that?

• Jason Brownlee March 31, 2019 at 9:32 am #

Perhaps try some of the methods listed in the above tutorial?

6. Henry May 10, 2019 at 10:18 pm #

Hi Jason,

I’m fairly new to econometrics and time series. I have a few questions about what you wrote.

You said “This means that all variables have the same variance (sigma^2) and each value has a zero correlation with all other values in the series.”

I thought that not being correlated with other independent variables was a good thing since it avoid multicollinearity.

Also, you said that “Does the variance change over time?” I thought for a time series analysis, you need to have a constant variance in order to have stationarity. Correct me if I’m wrong but I thought that before doing a time series, you must convert a non-stationary data into a stationary form ( perhaps by using differencing). But wouldn’t the “variance change over time” violate stationarity?

Thanks for the help! 🙂

• Jason Brownlee May 11, 2019 at 6:16 am #

No, in a time series, we want a correlation for a variable with prior time steps it tells us we have something linear we can learn.

Variance can change and we will have to power transform to make it stationary. But when we are looking at noise, we are checking if there is any pattern at all.

7. hong May 14, 2019 at 6:39 am #

Hi Jason,

Thanks for the post which is very helpful.

I understand that stationarity in data is required for forecasting. That is why we need to take the differences of the data which contains trends or seasonalities to make it stationary (constant mean, constant variance when we look at the graph). Now, the data becomes white noise (constant mean, constant variance)? But then, you said that we could not forecast a white noise series.
So it makes me so confused. Please correct me if I misunderstood something.

Thanks a lot for your help!

• Jason Brownlee May 14, 2019 at 7:54 am #

The idea is that there is some signal left after the trend and seasonality is removed. If there is not, then your job is done – you can model your series with a linear trend and seasonality.

8. Aditya Mahajan May 14, 2019 at 9:24 pm #

So we can conclude that we need to put effort to improve our model if our error series after modelling is not a white noise .
If its white noise than we have extracted essential information from the data set and our model contains those information.

• Jason Brownlee May 15, 2019 at 8:14 am #

Correct, if there is some signal remaining, then we can model it.

9. Samuel Corradi October 28, 2019 at 2:28 am #

You wrote: “Your time series is NOT white noise if any of the following conditions are TRUE:
– Does your series HAVE a zero mean?”

This is right?

Thanks!

• Jason Brownlee October 28, 2019 at 6:07 am #

I have made it clearer, thanks for pointing this out!