3
$\begingroup$

My data is:

d = {{0, 3.889}, {0.04, 3.941}, {0.06, 5.036}, {0.08, 12.589}, {0.1, 16.972}, {0.2, 13.200}, {0.4, 12.063}};

I need to fit a function as: $\log_b a + \log_b [x (1 - x)]$ and obtain the appropriate $a$ and $b$. Also, $0 < x < 1$.

So, I have:

FindFit[d, Log[b, a] + Log[b, x (1 - x)], {a, b}, x]

But I get several errors, such as: "Indeterminate expression 0. ComplexInfinity encountered."

How to overcome these errors?

$\endgroup$
2
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) 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, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Nov 9, 2021 at 11:37
  • 2
    $\begingroup$ Your data dshould include the x-values! $\endgroup$ Nov 9, 2021 at 11:49

1 Answer 1

4
$\begingroup$

I changed your model a little bit. First data point cann't be used because of Log[0]

Try

mod = NonlinearModelFit[Rest[d] , {a + b Log[ x (1 - x)], a > 0 }, {a, b }, x,Method -> "NMinimize"] //Quiet
Show[{Plot[mod[x], {x, 0, .4}], ListPlot[d]}]

enter image description here

$\endgroup$
4
  • $\begingroup$ Why did you restrict on logarithmic model? $\endgroup$ Nov 9, 2021 at 12:42
  • $\begingroup$ You're welcome! $\endgroup$ Nov 9, 2021 at 13:15
  • 1
    $\begingroup$ @UlrichNeumann shouldn't you impose restrictions like $b\neq 1$ and $b>0$? $\endgroup$
    – rhermans
    Nov 9, 2021 at 13:39
  • 2
    $\begingroup$ @rhermans The original model from question would require these constraints, the model in my answer doesn't need these constraints. $\endgroup$ Nov 9, 2021 at 13:43

Your Answer

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

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