1

I would like to fit this data with a function f(x), where f(x) = (K)(xlog(x) + (1-x)log(1-x)) + Ax*(1-x) + B*(x)*2(1-x)**2, and K, A, B are the fitted constants. And, This is what I have until now, where green solid line is the fitted curve. Here is the Data and below my gnuplot script

f(x)= (K)*(x*log(x) + (1-x)*log(1-x)) + A*x*(1-x) + B*(x)**2*(1-x)**2
pl '1417.dat' u 1:2
fit f(x) '1417.dat' u 1:2 via K,A,B

Obtained K = 8116.63, A = 2.20, B=43692

I need to fit accurately at the minima regions, can anyone suggest how to fit with less deviation.

3
  • Add your data and the gnuplot script, please. Commented Feb 18, 2021 at 11:13
  • Your fit function is symmetric within the [0, 1] region. You can see this if you replace x by 1-x everywhere => your function will not change. In contrast, the data is not symmetric. So basically the fit function will not match the data. You should check the physical background of your data. Maybe a linear term (+C+D*x) might help? Commented Feb 18, 2021 at 11:20
  • @maij I've added the data and the script Commented Feb 18, 2021 at 11:23

2 Answers 2

2

I guess something must be "wrong" with your function/model (or with your data). If k(x), a(x), and b(x) are all symmetric functions to x=0.5, and so is f(x). How should the sum of 3 symmetric functions give an asymmetric function?

Code:

### impossible fitting
reset session

FILE = "SO/1417.dat"

k(x) = K*(x*log(x) + (1-x)*log(1-x))
a(x) = A*x*(1-x)
b(x) = B*x**2*(1-x)**2

f(x)= k(x) + a(x) + b(x)

set fit nolog
fit f(x) FILE u 1:2 via K,A,B

plot FILE u 1:2, k(x), a(x), b(x), f(x) lw 2 lc "red"
### end of code

Result:

enter image description here

Sign up to request clarification or add additional context in comments.

1 Comment

thanks for your ans. yes, you are correct, I believe I need to add linear functions like, G1*x+G2*(1-x), where G1 and G2 are constants.
1

For example the slightly different function below allows a better fitting :

enter image description here

Note that ln(x)ln(1-x) is exactly equal to zero at x=0 and x=1.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.