Imported from https://github.com/v0lta/fourier-prediction