Bio*_*per 2 r gnuplot curve-fitting
对于一个简单的xy散点图,我可以用R或gnuplot以什么方式应用幂拟合曲线?我有一个包含两列的文件.
要举例说明使用gnuplot进行曲线拟合,请考虑以下数据集data.txt:
0.5 0.8
2.4 9.3
3.2 37.9
4.9 68.2
6.5 155
7.8 198
Run Code Online (Sandbox Code Playgroud)
与幂律函数的拟合可能如下所示:
set termoption enhanced
f(x) = a*x**b;
fit f(x) 'data.txt' via a,b
plot 'data.txt' with points title 'data points', \
f(x) with lines title sprintf('power fit curve f(x) = %.2f·x^{%.2f}', a, b)
Run Code Online (Sandbox Code Playgroud)
使用终端设置
set terminal pngcairo size 800,600 font ',12'
Run Code Online (Sandbox Code Playgroud)
这给出了结果

当然,这是最基本的适应方式,"专业"取决于您的实际需求.