<jupyter_start><jupyter_text>ACFAutocorrelation Coefficient (ACF) $r_{k}$ is defined as:$$r_{k} = \frac{\sum\limits_{t=k+1}^N (a[t]-\bar{a})(a[t-k]-\bar{a})} {\sum\limits_{t=1}^N (a[t]-\bar{a})^2}, $$where$$\bar{a} = \frac{1}{N} \sum\limits_{t=1}^N a[t].$$.The autocorrelation $r_{k}$ determines the autocorrelation strength and signiture between $a[t]$ and $a[t-k]$.**Special case**: when a times series is produced such that $a[t] = \alpha\times a[t-1]$ and $0<\alpha<1$, and $N$ is large engouth, then for small $k$s we will have:$$r_{k} \approx \alpha^k$$<jupyter_code>times = np.arange(2*365+1)
series = autocorrelation(times, 0.3, 123, 0.5)
_ = plot_acf(series)
plot_times_series(times, series)
# ACF Plot for white nosie
times = np.arange(2*365+1)
noise_series = white_noise(times)
_ = plot_acf(noise_series, title="Autocorrelation Plot for White Noise", zero=True)
plot_times_series(times, noise_series)<jupyter_output><empty_output><jupyter_text>Random Walk<jupyter_code>times = np.arange(2*365+1)
random_walk_series = random_walk(times, seed=123)
plot_times_series(times, random_walk_series)
_ = plot_acf(random_walk_series, title="Autocorrelation for Times Series of Random Walk", lags=100)
random_walk_difference_series = random_walk_series[1:] - random_walk_series[0:len(random_walk_series)-1]
plot_times_series(times[1:], random_walk_difference_series)
_ = plot_acf(random_walk_difference_series)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16319444444444445, 'fraction_numerical': 0.027777777777777776, 'mean_word_length': 8.178343949044587, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '186432', 'license': 'MIT', 'n_tokens_mistral': 586, 'n_tokens_neox': 554, 'n_words': 104, 'path': 'Lecture-01.ipynb', 'repo_name': 'javadebadi/times-series-course', 'size': '1440'}