# Need help in making a fit to my experimental data

This is what I have done so far. The points are of angles-of-deviation and wavelengths from my physics lab experiment.

V = ListPlot[
{{589.3, 53.50}, {435.8, 56.02}, {535.4, 54.52}, {546.1,
53.57}, {577.0, 53.13}, {690.9, 52.10}, {402.6, 55.72}, {447.2,
55.02}, {492.2, 54.53}, {501.6, 54.83}, {587.6, 53.03}, {667.8,
52.83}, {706.5, 52.05}
}, PlotRange -> {{400, 710}, {50, 60}},
AxesLabel -> { wavelength, deviation}, PlotStyle -> Red,
GridLines -> Automatic]


I am trying to find the best fit line of these points. I know it is some type of exponential function. But I can not figure out how to do it. Please help me out.

-
The relation appears to be linear. Why not use regression? –  David Carraher Nov 12 '13 at 2:35
Which is the dependent and which is the independent variable (or are both independent)? Regression of y with respect to x is not the same as regression of x with respect to y. –  geordie Nov 12 '13 at 4:20
@geordie. Very good point. That makes me suspect that the (linear) Fit that I used below works differently from regression. –  David Carraher Nov 12 '13 at 5:17
@geordie If the experiment is to calibrate one set of measurements to the other, as taya suggests in a comment to dwa, then the standard measure would presumably correspond the dependent variable. –  David Carraher Nov 12 '13 at 5:27
@DavidCarraher. Given the scatter in both x and y, it seems reasonable to assume there is an uncertainty associated with each measurement - in which case a simple linear regression (least squares, etc.) will produce an unreliable fit. Better methods are available using robust stats. Then again, perhaps I'm over thinking this... –  geordie Nov 13 '13 at 1:06

Given the distribution of the data, you should use linear model, unless you have compelling theoretical reasons for believing the model is not linear.

data = {{589.3, 53.50}, {435.8, 56.02}, {535.4, 54.52}, {546.1, 53.57}, {577.0, 53.13},{690.9, 52.10}, {402.6, 55.72}, {447.2, 55.02}, {492.2, 54.53}, {501.6, 54.83}, {587.6,53.03}, {667.8, 52.83}, {706.5, 52.05}};
Show[
ListPlot[data, PlotRange -> {{400, 710}, {50, 60}}, AxesLabel -> {"wavelength", "deviation"},
PlotStyle -> Red, GridLines -> Automatic],
Plot[Evaluate@Fit[data, {1, x}, x], {x, 400, 710}]
]


-
The Dungeon Master told them it's an exponential. That's what I call a compelling experimental reason. –  belisarius Nov 12 '13 at 3:01
@belisarius hits the evil dungeon master with his comment of snarkiness +1? –  bobthechemist Nov 12 '13 at 3:13
@bobthechemist It was with the hammer of cynicism (+1 to hit, +3 damage) –  belisarius Nov 12 '13 at 3:27

It's straightforward, and can get gleaned from the documentation.

After Sort@data,

nfit = NonlinearModelFit[data, a Exp[-t/\[Tau]], {a, \[Tau]}, t]
Show[{V,
Plot[nfit[t], {t, 400, 710}]
}
]


will compare your experimental data to an exponential fit. Documentation on NonlinearModelFit gets you a bunch of diagnostics.

Having said that, after looking at \[Tau], why not fit a linear function?

-
Thank you so much. –  taya Nov 12 '13 at 1:42
in the lab hand out, the professor gave the example graph that the calibration curve should resemble a curve line,,, which i guess it some kind of exponential... –  taya Nov 12 '13 at 1:45
I see no reason to sort the data. Am I missing something. –  David Carraher Nov 12 '13 at 2:53
No compelling reason, since NonlinearModelFit appears to handle data 'as is'. –  dwa Nov 12 '13 at 3:28