# 3 Types of Seasonality and How to Detect Them | by Vitor Cerqueira | Jun, 2023

There are three types of seasonal patterns that can emerge in time series. Seasonality can be deterministic or stochastic. On the stochastic side, seasonal patterns can be either stationary or not.

These types of seasonality are not mutually exclusive. A time series can have both a deterministic and stochastic seasonal component.

Let’s describe each pattern in turn.

## Deterministic seasonality

Time series with a deterministic seasonality have a constant seasonal pattern. It always recurs in a predictable way, both in intensity and periodicity:

• similar intensity: the level of the seasonal pattern stays the same over the same seasonal period;
• unchanged periodicity: the location of the peaks and troughs does not change. In other words, the time between each repetition of the seasonal pattern is constant.

Here’s a synthetic monthly time series with a deterministic seasonality:

`import numpy as npperiod = 12size = 120beta1 = 0.3beta2 = 0.6sin1 = np.asarray([np.sin(2 * np.pi * i / 12) for i in np.arange(1, size + 1)])cos1 = np.asarray([np.cos(2 * np.pi * i / 12) for i in np.arange(1, size + 1)])xt = np.cumsum(np.random.normal(scale=0.1, size=size))series_det = xt + beta1*sin1 + beta2*cos1 + np.random.normal(scale=0.1, size=size)`

This time series is adapted from the book in reference [3].

Constant seasonality can be well handled by seasonal dummy explanatory variables. A categorical variable that describes the seasonal period. In this case, the month that corresponds to each time step. This categorical variable is transformed into a set of indicator (dummy) variables by one-hot encoding.

You can also use Fourier series to model seasonality. Fourier series are sine and cosine waves with varying periods. You can learn more about these in a previous article.

## Stochastic stationary seasonality

`beta1 = np.linspace(-.6, .3, num=size)beta2 = np.linspace(.6, -.3, num=size)sin1 = np.asarray([np.sin(2 * np.pi * i / 12) for i in np.arange(1, size + 1)])cos1 = np.asarray([np.cos(2 * np.pi * i / 12) for i in np.arange(1, size + 1)])xt = np.cumsum(np.random.normal(scale=0.1, size=size))# synthetic series with stochastic seasonalityseries_stoc = xt + beta1*sin1 + beta2*cos1 + np.random.normal(scale=0.1, size=size)`

A stochastic stationary seasonality evolves over consecutive seasonal periods (e.g. year over year). The intensity is less predictable, but the periodicity stays roughly the same.

With deterministic seasonality, the best prediction for a given month doesn’t change irrespective of the year. For a stochastic stationary seasonality, the best guess depends on the value of the same month from the previous year.

## Stochastic non-stationary seasonality

Sometimes, seasonal patterns change significantly over several seasonal periods. These changes can be caused by seasonal unit roots, which means that seasonality is integrated.

Besides the intensity, the periodicity of this type of seasonality also tends to change over time. This means that the peaks and troughs vary in their location.

Examples of this type of seasonal pattern appear in different domains. These include consumption series or industrial production data.

Changes are difficult to predict when time series have an integrated seasonality. Shocks cause permanent changes in the data, leading to scenarios where “spring becomes summer” — quote from reference [1].