1

I have two functions, say $f(x)$ and $g(x)$, being the first the 'observed' and the second the 'theoretical', which can be variable. What I aim to find is the $g(x)$ that best approximates to $f(x)$. Both functions are discrete, and I have 14 points in abscissa for which I can compare the value of both of them.

What I do (in Python) is calculate a simple difference of $f(x)$ and $g(x)$ for each one of this points, then I calculate the average of those (14) differences, and change my $g(x)$ model (which changes the shape of the function subtly) to see if this original $g(x)$ indeed minimizes the difference with $f(x)$.

Is there some more robust statistic to apply here? For example, $\chi^2$?

See functions whose difference is to be minimized here. Blue is $g(x)$ in this context and can be treated as a discrete function.

cwasdwa
  • 11
  • 1
    There is not enough information here. Usually, you have a space of test functions specified by a collection of parameters. Then you can ask for the parameter that set that passes whatever test you favor (minimize least square differences being the typical choice, but there are other sensible choices depending on the context). – lulu Aug 23 '17 at 15:51
  • 1
    Note: averaging simple differences seems like a bad idea. Huge errors of different signs cancel each other so a "good score" might belie an absolutely terrible fit. Also, it isn't clear what "minimum" means in this context. If you have two values $(0,1),(0,-1)$ and seek a constant fit, then taking any $c\in [-1,1]$ your score is $\frac 12 \times \left((1-c)+(-1-c)\right)=-c$, so what's the best fit? – lulu Aug 23 '17 at 15:52
  • Yes, that's a good point. I just edited the original post adding the image with the functions whose distance is to be minimized. That is, I want the model (in blue) to be plotted right on the observed data (in red). I have several models I can test with, so I can find the one that fits best. By fitting best here I mean to minimize the distance between the points (ignore the first two) and the corresponding value in the model. I think int his case it would be valid to take absolute values of the differences and find the model that reduces the offsets, independently of their sign... – cwasdwa Aug 23 '17 at 16:37
  • Minimizing the absolute differences is certainly a standard method, though you might want to read about the reasons people tend to use Least Squares instead, see this for example. Often people try multiple "cost functions" and see which gives the "best" answers for their particular situation. – lulu Aug 23 '17 at 16:52
  • Thank you, for the case I am using it for, it seems more than reasonable to use LS. – cwasdwa Aug 24 '17 at 16:52

0 Answers0