0

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!

Stitch
  • 4,205
  • 1
  • 12
  • 28
Nyxvis
  • 1
  • 1
  • 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! – Szabolcs Apr 06 '17 at 11:16
  • 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 – Nyxvis Apr 06 '17 at 11:24
  • 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 https://www.wolfram.com/mathematica/resources/ and http://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. – Szabolcs Apr 06 '17 at 11:28
  • 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 – Nyxvis Apr 06 '17 at 11:37
  • NonlinearModelFit calls FindFit too. – Szabolcs Apr 06 '17 at 11:41

1 Answers1

1

Use NonlinearModelFit:

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

fm["FitResiduals"]
Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263