Generate a best fit polynomial function from an arbitrary set of data in javascript