r,ggplot2,curve-fitting,best-fit-curve,curvesmoothing

Using some mock data from ggplot2 stat_smooth examples since you didn't provide any. You'll need to do some math on the resultant data.frame calculated by stat_smooth: library(ggplot2) library(splines) library(MASS) p1 <- ggplot(mtcars, aes(qsec, wt)) p2 <- p1 + stat_smooth(method = "lm", formula = y ~ ns(x,3)) + geom_point() gb <-...

I think there is a confusion here between smoothing (i.e filtering), interpolation and curve fitting, Filtering / smoothing: we apply an operator on the data that modifies the the original y points in a way to remove high frequency oscillations. This can be achieved with for instance with scipy.signal.convolve, scipy.signal.medfilt,...