Searches for the optimal values of k and d for a given time series. First,
values corresponding to instants from initial + 1 to the last one are
predicted. The first value predicted, which corresponds to instant
initial + 1, is calculated using instants from 1 to instant initial; the
second value predicted, which corresponds to instant initial + 2, is
predicted using instants from 1 to instant initial + 1; and so on until last
value, which corresponds to instant n (length of the given time series), is
predicted using instants from 1 to instant n - 1. Finally, the error is
evaluated between the predicted values and the real values of the series.
This version of the optimization function uses a parallelized distances
calculation function, and the computation of the predicted values is done
parallelizing by the number of d's.