如何找到可能的指数近似的系数

时间:2015-05-14 13:26:14

标签: matlab octave curve-fitting data-fitting

我有这样的数据:

y = [0.001
     0.0042222222
     0.0074444444
     0.0106666667
     0.0138888889
     0.0171111111
     0.0203333333
     0.0235555556
     0.0267777778
     0.03]

x = [3.52E-06
     9.72E-05
     0.0002822918
     0.0004929136
     0.0006759156
     0.0008199029
     0.0009092797
     0.0009458332
     0.0009749509
     0.0009892005]

我希望yx的函数,y = a(0.01 - b * n ^ -cx)。

找到适合数据的系数abc的最佳组合,最简单,最简单的计算方法是什么?

我可以使用Octave吗?

1 个答案:

答案 0 :(得分:2)

你的功能

  

y = a(0.01 - b * n -cx

是一个非常具体的形式,有4个未知数。为了从您的观察列表中估算您的参数,我建议您简化它

  

y =β 1 2 β 3 x

这成为我们的目标函数,我们可以使用普通的最小二乘法来求解一组好的beta。

在默认的Matlab中,您可以使用fminsearch来查找这些β参数(让我们称之为参数向量, β ),然后您就可以使用简单的代数回到abcn(假设您事先知道bn)。在Octave中,我确信你可以找到一个等效函数,我将从这里开始:http://octave.sourceforge.net/optim/index.html

我们打算致电fminsearch,但我们需要以某种方式传递您的观察结果(即xy),我们将使用匿名函数执行此操作,因此就像示例2来自文档:

beta = fminsearch(@(x,y) objfun(x,y,beta), beta0) %// beta0 are your initial guesses for beta, e.g. [0,0,0] or [1,1,1]. You need to pick these to be somewhat close to the correct values.

我们定义了这样的目标函数:

function sse = objfun(x, y, beta)
    f = beta(1) + beta(2).^(beta(3).*x);
    err = sum((y-f).^2); %// this is the sum of square errors, often called SSE and it is what we are trying to minimise!
end

所以把它们放在一起:

y= [0.001; 0.0042222222; 0.0074444444; 0.0106666667; 0.0138888889; 0.0171111111; 0.0203333333; 0.0235555556; 0.0267777778; 0.03];
x= [3.52E-06; 9.72E-05; 0.0002822918; 0.0004929136; 0.0006759156; 0.0008199029; 0.0009092797; 0.0009458332; 0.0009749509; 0.0009892005];
beta0 = [0,0,0];

beta = fminsearch(@(x,y) objfun(x,y,beta), beta0)

现在,您可以根据abc解决beta(1)beta(2)beta(3)的问题。在纸上做。

相关问题