-
Notifications
You must be signed in to change notification settings - Fork 36
Description
It's common to have (x,y) scatterplot data and want to fit a nice best-fit curve through that data for visualization. It'd be great if Eidos had a way to do this. There are many ways of curve-fitting, of course. Some guarantee that the fitted curve actually passes through all the points in question; that is not what I have in mind (although doubtless useful in some situations). What I have in mind is fitting a curve, preferably without any predetermined functional form, that is in some sense a "best fit" to the data without responding too sensitively to any one data point. AFAICT this is quite complicated and requires iterative numerical approximation and so forth. Not necessarily out of the question, but I'd prefer not to have to figure it all out for myself, so I'm hoping for a simple C++ implementation of something open-source that I can just throw into Eidos.
I found https://github.com/ttk592/spline but I think (?) it only fits curves that exactly pass through all points; not what I want.
Then I found https://software.nasa.gov/software/MSC-26693-1 which is on GitHub at https://github.com/nasa/polyfit. It looks pretty reasonable? It only fits polynomials, of a degree that the user specifies, so that's not ideal; I'd rather have something that fits a simple function to data that follow a simple pattern, and fits a complex function to data that follow a complex pattern, automatically. I suppose I could add a front end to this library that tries polynomials up to some limit order (square root of number of data points or some such, with a max of ~20?), and chooses the lowest-order polynomial with a "good" R2 according to some heuristic. But ugh; I was hoping to avoid that kind of heuristics. It's also not ideal that its license is unclear and it says "The program has been reviewed and approved by export control for public release. However some export restriction exists. Please respect applicable laws." That is really ambiguous and I don't know whether I can legally incorporate it in SLiM. :-<
I've found other libraries that can do more than polyfit, but there is a huge step upward in complexity, such that they are not usable in Eidos; e.g., http://ceres-solver.org.
See #527 for the context in which this originally arose.
Ideas, @petrelharp or @vsudbrack or anybody else?