在gnuplot中获取拟合的导数

时间:2014-01-22 01:55:12

标签: gnuplot

这是我之前的问题here

的扩展

data.dat中的数据集,代码和数字是, FILE.DAT:

x       y 
2.53    0.00
0.70    0.99
0.60    2.45
0.49    5.36
0.40    9.31
0.31    18.53
0.22    30.24
0.11    42.23

代码:

f(x) = (x < 0 ? 0 : a*(x/lambda)**(n-1)*exp(-(x/lambda)**n))
n = 0.5
a = 100
lambda = 0.15
fit f(x) 'data.dat' every ::1 via lambda, n, a

set encoding utf8
plot f(x) title sprintf('λ = %.2f, n = %.2f', lambda, n), 'data.dat' every ::1

图:

enter image description here

我的目标是得到x的值(在图中它大约是x = 1)来找到&#34;上升&#34;适合的功能。所以我想知道是否有可能在飞行中采用拟合的一阶导数并将其绘制在gnuplot中的相同图形中?二阶导数怎么样? TIA。

1 个答案:

答案 0 :(得分:1)

如果你不介意自己分析地获取拟合函数的导数,这很容易:

f(x) = (x < 0 ? 0 : a*(x/lambda)**(n-1)*exp(-(x/lambda)**n))
fp(x) = (x < 0 ? 0 : a*(n-1)*x**(n-2)*exp(-(x/lambda)**n)/lambda**(n-1)*(1 - a*(x/lambda)**n))

plot 'data.dat' title 'data', f(x) title 'fit', fp(x) title 'derivative of fit'

如果你想使用gnuplot函数来做导数,gnuplot必须用数字方式进行导数(例如使用this example中的多点方法),所以如果你有几个数据点。

分析性地使用衍生物或使用非gnuplot程序进行这种分析几乎肯定会更好。