Add a function for direction correction

direction.correction() was added to detect and correct the reversed
prediction.