-2
$\begingroup$

Does anybody know why my model is picking the wrong values for DN & T?

enter image description here

$\endgroup$

closed as off-topic by Daniel Lichtblau, Bob Hanlon, corey979, MarcoB, Wjx Oct 2 '16 at 5:11

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Daniel Lichtblau, Bob Hanlon, corey979, MarcoB, Wjx
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    $\begingroup$ Please share the code in a code-block directly as text and not as image. Please refer to the editing-help to see how you can do this and a short look over the faq won't hurt either. $\endgroup$ – halirutan Sep 24 '16 at 14:02
  • $\begingroup$ The default starting values are both 1 for T and DN. Change those to 12 and 0.11 and FindFit will converge to the correct values (although the fit isn't so hot for large values of t). $\endgroup$ – JimB Oct 1 '16 at 6:18
2
$\begingroup$

There are at least two reasons why the desired fit is "difficult" for this combination of curve and data.

First, the sum of squares for various values of T and DN is kinda lumpy. In the figure below the green dot is the default starting value and the red dot is the desired solution (in the sense that those values minimize the sum of squares).

sst[T_, DN_] := Total[(data[[All, 2]] - cout[1, 0.5, 0.5 T, DN, data[[All, 1]], T])^2]
Show[ContourPlot[sst[T, Exp[logDN]], {T, 0.5, 15}, {logDN, -4, 1},
  PlotPoints -> 50, PlotRange -> {All, All, {0, 4}}, ContourLabels -> All,
  Contours -> {0.001, 0.01, 0.05, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1, 2, 3, 4},
  FrameLabel -> (Style[#, Large, Bold] & ) /@ {"T", "Log[DN]"}],
 ListPlot[{{{12.8369, Log[0.0799443]}}, {{1, 0}}}, 
  PlotStyle -> {{Red, PointSize[0.02]}, {Green, PointSize[0.02]}}]]

Contour plot of sum of squares for values of T and DN

Second choosing starting values closer to the final solution helps. ("One can't beat good starting values.") If one uses what you tried in your question (T = 12 and DN = 0.11), then the desired solution is found.

FindFit[data, cout[1, 0.5, 0.5 T, DN, t, T], {{T, 12}, {DN, 0.11}}, t]
(* {T -> 12.836895298848031`,DN -> 0.07994429793304991`} *)
$\endgroup$

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