1
$\begingroup$

my problem goes as follows:

I need to a discrete fit of a discrete function. Say I have the following made up data points, which are generated by the parabola f[x_]:=x^2 with some "experimental error" added:

data := {{-3, 8.9}, {-2, 4.1}, {-1, 1}, {0, 0}, {1, 1.2}, {2, 3.9}, {3,9.2}};
valuex := {-3, -2, -1, 0, 1, 2, 3}
valuey := {8.9, 4.1, 1, 0, 1.2, 3.9, 9.2}

These points should be fitted by a curve of the general formula f[x_]:= a*x² + b*x + c, and I built a NMinimize algorithm as:

Minimize[Sqrt[Plus @@ ((a*valuex^2 + b*valuex + c - valuey )^2)], {a, b, c}]

This gives off a pretty accurate value for a, b and c

{0.282, {a -> 0.99881, b -> 0.025, c -> 0.0476191}}

these are basically the same values I got when using NonlinearModelFit

nmf = NonlinearModelFit[data, a x^2 + b x + c, {a, b, c}, x]
FittedModel[0.047619+0.025x+0.99881x^2 

Now what nmf gives me, that I need to calculate in the NMinimize case is the nmf["ParameterErrors"], {0.0153843, 0.0266465, 0.0814063}.

How can I do that manually? I tried looking it up how NonlinearModelFit does it, but my lack of mathematical knowledge is making things pretty hard.

Any help regarding that matter is welcomed!

Thanks in advance.

p.s.: I don't know if I made it clear enough, but that is just an example function. The one I need to fit is much more complicated and cannot be analytically evaluated, making NMinimize essential.

$\endgroup$
  • $\begingroup$ My post used to begin with "Hello all, " but somehow that got deleted. I tried editing to add it again and nothing. Are headers like that automatically excluded? Anyway, just letting you know what was the edit about. $\endgroup$ – LeFerret Nov 5 '14 at 20:05
  • $\begingroup$ Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Nov 5 '14 at 20:41
  • $\begingroup$ @LeFerret Yes, generally posts are to be statements of questions, with whatever background etc is necessary. Not in "letter" format (no salutations, no closings). I didn't realize the SE bot catches some of that stuff. $\endgroup$ – Michael E2 Nov 5 '14 at 21:23
  • $\begingroup$ Related: stats.stackexchange.com/questions/72047/… $\endgroup$ – Michael E2 Nov 5 '14 at 21:26
  • $\begingroup$ @Lou: Thank you for the calrification. $\endgroup$ – LeFerret Nov 5 '14 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.