So the basic idea is to choose the four parameters in the sine wave in such a way that they minimize the total squared error of the fit to the data. Accordingly, this approach is called the method of least squares. It works best when the data follow a pattern, as they do here.