0
$\begingroup$

I am trying to make data and fit it tp a power law model. but it doesn't work. I don't know what the problem is.

mample = 1.05295;
sigma = 0.509317;
model = a*x^c
data = 
  Table[
    {x, mample*(1/(sigma*Sqrt[2*Pi]))*Exp[-(1/2)*(((x)/sigma)^(2))]}, 
    {x,0, 2.1, 0.05}];
nlm = NonlinearModelFit[data, model, {a, c}, x]
Plot[nlm[x], {x, 0, 2.1}, Epilog -> Point[m], PlotRange -> All]
$\endgroup$
  • $\begingroup$ Change the plot command to Plot[Normal[nlm], {x, 0, 2.1}, PlotRange -> All] (Point[m] isn't defined) $\endgroup$ – Ulrich Neumann Apr 30 '19 at 9:35
1
$\begingroup$

The model a*x^c doesn't fit the data very well.

Try for example a rational approximation

model = (a + b x^2)/(1 + c x^2 + d x^4)
nlm = NonlinearModelFit[data, model, {a, b, c, d} , x]
Show[{Plot[Normal[nlm], {x, 0, 2.1}, PlotRange -> All],ListPlot[data]}]

enter image description here

to get better approximation.

| improve this answer | |
$\endgroup$
  • $\begingroup$ Thanks Neumann! $\endgroup$ – Gwanwoo Apr 30 '19 at 11:29

Your Answer

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

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