Gnuplot 数据适合日志函数
Gnuplot data fit with log functions
我想要 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, is what I have until now, where green solid line is the fitted curve. Here is the Data 和我的 gnuplot 脚本
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
得到K=8116.63,A=2.20,B=43692
我需要在最小值区域准确拟合,谁能建议如何以较小的偏差进行拟合。
我想您的function/model(或您的数据)一定有什么地方“不对”。
如果k(x)
、a(x)
、b(x)
都是x=0.5
的对称函数,f(x)
也是。
3个对称函数之和应该如何给出一个不对称函数?
代码:
### 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
结果:
例如,下面稍微不同的函数可以更好地拟合:
请注意,ln(x)ln(1-x) 在 x=0 和 x=1 时正好等于零。
我想要
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
得到K=8116.63,A=2.20,B=43692
我需要在最小值区域准确拟合,谁能建议如何以较小的偏差进行拟合。
我想您的function/model(或您的数据)一定有什么地方“不对”。
如果k(x)
、a(x)
、b(x)
都是x=0.5
的对称函数,f(x)
也是。
3个对称函数之和应该如何给出一个不对称函数?
代码:
### 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
结果:
例如,下面稍微不同的函数可以更好地拟合:
请注意,ln(x)ln(1-x) 在 x=0 和 x=1 时正好等于零。