Least-squares signal extrapolation (linear prediction)

Introduction
Least squares method can be used to find patterns (correlations) in a signal which can then be used to extrapolate the signal (see the lecture note).
Task