I have some data:


That I plot with ListPlot. I have two functions that I would like to check which one of them best fits my data. The functions are:

f1[x_]:=0.5 x + (4/2) x^3
f2[x_]:=0.5 x + (5/2) x^3 + 80

and I plot them along with data points that I have I get a plot: enter image description here

Function f2 is plotted red, and function f1 is plotted blue. Function f2 is seems to be the best fit to data points, but is there a way in which I can in Mathematica check this, not by using something like FindFit or NonlinearModelFit, but instead calculating say distances between points and plots and see which function gets data points closer to it. Is this a correct way of thinking about fitting? Is there a code that allows checking how close are data points to some model function, or two of them or even more?

  • 1
    $\begingroup$ The answer will depend on the error bars. Are they the same for all data points? Or are they proportional to the values? Or something else? $\endgroup$
    – Roman
    Jul 8, 2019 at 12:34

1 Answer 1


One possible way is to use RootMeanSquare on errors when f1 /@ x and f2 /@ x are used as predictions for y:

RootMeanSquare /@ {f1 /@ x - y, f2 /@ x - y}

{222.43, 79.95}


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.