Non-linearlized data averaging algorithm and hard-coded determineDirection() funtion for troubleshooting purposes.