0
$\begingroup$

I have read through other forum posts and have seen a few things that I thought would help but I am still having issues. I'm trying to fit some calibration data and am at first getting the error shown on the attached picture.

fit error 1

I saw in a forum post that putting constraints on the fit function can help, so I tried restricting the value for "t" as shown in the second picture but I am not getting a fit. Anything else I do to try to constrain the fit does not help.

fit error 2

Any help would be greatly appreciated! Thanks.

$\endgroup$

2 Answers 2

3
$\begingroup$

There is a missing value for 9000 which is problematic. Further, rescaling helps to deal with overflow errors.

data = {{0, 33.5}, {1000, 33.5}, {2000, 33}, {3000, 30.8}, {4000, 
    27}, {5000, 22.4}, {6000, 17}, {7000, 12.8}, {8000, 8.8}, {10000, 
    5.45}, {11000, 4.5}, {12000, 3.7}, {13000, 3}, {14000, 
    2.5}, {15000, 2.05}, {16000, 1.7}, {17000, 1.4}, {18000, 
    1.15}, {19000, 0.88}, {20000, 0.72}, {21000, 0.6}, {22000, 
    0.49}, {23000, 0.42}};
nlm = NonlinearModelFit[{#1/1000, #2} & @@@ data, 
  a Exp [- b t^2], {{a, 33}, {b, 0.01}}, t]

Visualizing:

lab = Normal[nlm] /. t -> x/1000
Plot[nlm[x], {x, 0, 20}, PlotLabel -> lab, 
 Epilog -> {Point[{#1/1000, #2} & @@@ data]}, Frame -> True, 
 FrameTicks -> {Table[{j, 1000 j}, {j, 5, 20, 5}], Automatic}]

enter image description here

Note I typed values of data so may have errors but approach I hope is instructive.

$\endgroup$
1
  • $\begingroup$ Thank you so much. I didn't realize it would be a problem having a missing value. I appreciate the input! $\endgroup$
    – Azathoth
    Mar 25, 2015 at 6:18
1
$\begingroup$

The message should be your first hint. Nonetheless:

ListLinePlot[data]

enter image description here

See anything strange? The data at point 9000 is incomplete.

Let's interpolate for a test:

interp = Interpolation[data[[Drop[Range@24, {10}]]], 9000];
data[[10]] = {9000, %};

model=NonlinearModelFit[data, a1 Exp[-t^2/t1], {a1, t1}, t]

enter image description here

$\endgroup$
4
  • $\begingroup$ unfortunately the fitted model 33.5 $e^(-t^2}$ does not really fit the data as by t much less than 5000 it would by "vanishingly" small...some rescaling and starting values needed $\endgroup$
    – ubpdqn
    Mar 20, 2015 at 5:51
  • $\begingroup$ @ubpdqn: Yes, I was not interested in the correctness of the model, just answering the why of the error... $\endgroup$
    – ciao
    Mar 20, 2015 at 5:54
  • $\begingroup$ point taken...instructive but leaving room for independent learning...hope you are well:) $\endgroup$
    – ubpdqn
    Mar 20, 2015 at 5:57
  • $\begingroup$ @ubpdqn: Yep - If you look at edits, I actually edited out the "this is a terrible model..." - figured OP would benefit from finding that out and experimenting. Thanks for well wishes - smoking a cigar and playing with math - what's not to like ;-) $\endgroup$
    – ciao
    Mar 20, 2015 at 6:03

Your Answer

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

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