Time series

adfuller on a short series.

adfuller tests a unit root. A short series is a demo — print the statistic and pvalue.

Goal

Run adfuller on a random walk vs white noise.

import numpy as np
from statsmodels.tsa.stattools import adfuller
rng = np.random.default_rng(0)
noise = rng.normal(size=40)
print(adfuller(noise)[0:2])
import numpy as np
from statsmodels.tsa.stattools import adfuller
rng = np.random.default_rng(0)
walk = np.cumsum(rng.normal(size=40))
print(adfuller(walk)[0:2])
import numpy as np
print(np.cumsum([1, -1, 1, -1]))
import pandas as pd
print(pd.Series([80, 60, 110, 90]).diff().dropna().tolist())