0
$\begingroup$

my professor is asking to find the mean of the difference between:

data={{1.6, 2.3}, {2.2, 2.}, {3.4, 1.8}, {2., 2.1}, {0.1, 6.1}, {1.9, 
  2.2}, {3., 1.9}, {2.8, 1.9}, {3.3, 1.8}, {1.3, 2.4}, {2.2, 
  2.}, {1.7, 2.3}, {3., 1.9}, {1.8, 2.2}, {2.7, 2.}, {2.1, 2.1}, {2.8,
   1.9}, {4.9, 1.6}, {3.8, 1.7}, {0.6, 3.2}}

and the approximation curve found with FindFit[data,B (1/x)^g,{B,g},x] Is there any way to extrapolate some actual points from the FindFit function? I've already plotted it but I just don't know how to find the difference. Thank you in advance!

$\endgroup$
5
  • $\begingroup$ Use NonlinearModelFit and the "FitResiduals" property. Read the NonlinearModelFit documentation, including under "Details" and the examples. But I do not understand the question. You say that you used FindFit and got a result. You could plot the result. This means that you can compute its values in different points. What specific difficulty did you encounter when computing in at your original data points? In other words: show what you tried! $\endgroup$
    – Szabolcs
    Commented Apr 6, 2017 at 11:16
  • $\begingroup$ Mmh honestly I don't know the "FitResiduals" property, nor the "NonlinearModelFit" command. I had no problems plotting the function as "Plot[B (1/x)^g,{x,1,10}]", but that just gave me a plot, not a list of points. I have no idea how to calculate the mean of the distance between each data point and the fit curve because I don't know how to find the coordinates of the curve. I just started using Wolfram Mathematica, I only know a bunch of commands $\endgroup$
    – Nyxvis
    Commented Apr 6, 2017 at 11:24
  • $\begingroup$ You are trying to do too much at a time. If you do not know Mathematica at all, first you need to learn it. Start slow. Have you googled for tutorials? Take a look at wolfram.com/mathematica/resources and mathematica.stackexchange.com/q/18/12 The easiest way to solve your task is NonlinearModelFit. The most basic way with FindFit involves Table and Part. Please look these up. $\endgroup$
    – Szabolcs
    Commented Apr 6, 2017 at 11:28
  • $\begingroup$ Thank you for linking those tutorial, I'm gonna dig into them. I understand what you're saying, but my professor precisely asked me to use the "FindFit" command for finding those values, I don't have a choice unfortunately $\endgroup$
    – Nyxvis
    Commented Apr 6, 2017 at 11:37
  • $\begingroup$ NonlinearModelFit calls FindFit too. $\endgroup$
    – Szabolcs
    Commented Apr 6, 2017 at 11:41

1 Answer 1

1
$\begingroup$

Use NonlinearModelFit:

fm = NonlinearModelFit[data, B (1/x)^g, {B, g}, x]

fm["FitResiduals"]
$\endgroup$
0

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.