1
$\begingroup$

I have a following polynomial:

N*p1*x^(p2)*(1-x)^(p3)* (1+ p5*x^(p4) + p6*x) = f(x).

where N is a constant say N = 10.

I have values for f(x) for several x.

     x            f(x)
1.0000*10^-07 1.4013*10^+01
1.1767*10^-07 1.3689*10^+01
1.3846*10^-07 1.3372*10^+01
1.6293*10^-07 1.3063*10^+01
1.9171*10^-07 1.2761*10^+01
2.2559*10^-07 1.2466*10^+01
2.6545*10^-07 1.2178*10^+01
3.1235*10^-07 1.1896*10^+01
3.6754*10^-07 1.1621*10^+01
4.3248*10^-07 1.1352*10^+01
5.0890*10^-07 1.1090*10^+01
5.9882*10^-07 1.0833*10^+01
7.0462*10^-07 1.0583*10^+01
8.2912*10^-07 1.0338*10^+01
9.7562*10^-07 1.0099*10^+01
1.1480*10^-06 9.8775*10^+00
1.3509*10^-06 9.6558*10^+00
1.5895*10^-06 9.4310*10^+00
1.8704*10^-06 9.2031*10^+00
2.2009*10^-06 8.9727*10^+00

My question is:

  1. Is there any function in mathematica which can do this? I tried FindFit but it did not succeed.
  2. Is it possible to find the parameters p1, p2, p3, p4, p5, p6?
  3. What is the minimum number of data point needed to make such a fit?
$\endgroup$

closed as off-topic by happy fish, MarcoB, Daniel Lichtblau, Young, yohbs Jun 5 '17 at 20:06

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

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – happy fish, MarcoB, Daniel Lichtblau, Young, yohbs
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 1
    $\begingroup$ Make sure you import the data as numbers (and not as strings). Use ToExpression to convert strings looking like numbers to actual numbers. Then use NonlinearModelFit. Note that N is not be used as a variable name. NonlinearModelFit[data2, 10*p1*x^(p2)*(1 - x)^(p3)*(1 + p5*x^(p4) + p6*x), {p1, p2, p3, p4, p5, p6}, x] $\endgroup$ – Lotus May 31 '17 at 11:19
  • 1
    $\begingroup$ This doesn't answer your question but if this is your real data, you don't want to fit a polynomial. Look at ListLogLogPlot[data] and you'll see a straight line. No need for a high-order polynomial. $\endgroup$ – JimB May 31 '17 at 15:28
  • $\begingroup$ A piece of advice: don't use N as variable name. N is reserved for an important built-in function. Using it as a variable can shadow the function. $\endgroup$ – m_goldberg May 31 '17 at 15:30
  • $\begingroup$ do you want p2,p3,p4 to be restricted to integers? Otherwise its not a polynomial. $\endgroup$ – george2079 May 31 '17 at 17:46
  • $\begingroup$ @ago No, all pi can take any values. Its a function I want to fit to these data. $\endgroup$ – Boogeyman Jun 1 '17 at 3:17
5
$\begingroup$

Use Import to import data from a file:

data1 = Import["C:\\Users\\Aravind\\Desktop\\data.txt", "Data"]

Convert strings to numbers:

data2 = ToExpression /@ data1

nfit = 
  NonlinearModelFit[data2, 10*p1*x^(p2)*(1 - x)^(p3)*(1 + p5*x^(p4) + p6*x), 
    {p1, p2, p3, p4, p5, p6}, x]

nfit["BestFitParameters"]

(* {p1 -> 0.0196938, p2 -> 0.128675, p3 -> 215205., p4 -> -0.261865, 
 p5 -> 8.38579, p6 -> 6.17042*10^7} *)

lp = ListPlot[data2]

plt = Plot[nfit[x], {x, data2[[1, 1]], data2[[-1, 1]]}, PlotStyle -> Red]

Show[lp, plt]

enter image description here

$\endgroup$

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