如何找到可能的指数近似系数
How to find coefficients for a possible exponential approximation
我有这样的数据:
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]
我希望 y
是 x
的函数,其中 y = a(0.01 − b*n^−cx).
找到适合数据的系数 a
、b
和 c
的最佳组合的最佳和最简单的计算方法是什么?
我可以使用 Octave 吗?
你的函数
y = a(0.01 − b*n−cx)
是一个非常特殊的形式,有 4 个未知数。为了从你的观察列表中估计你的参数,我建议你简化它
y = β1 + β2β3x
这成为我们的 objective 函数,我们可以使用普通最小二乘法求解一组良好的贝塔值。
在默认的 Matlab 中,您可以使用 fminsearch
to find these β parameters (lets call it our parameter vector, β), and then you can use simple algebra to get back to your a
, b
, c
and n
(assuming you know either b
or n
upfront). In Octave I'm sure you can find an equivalent function, I would start by looking in here: http://octave.sourceforge.net/optim/index.html。
我们将调用 fminsearch
,但我们需要以某种方式传递您的观察结果(即 x
和 y
),我们将使用匿名函数来实现,所以就像文档中的示例 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.
我们这样定义 objective 函数:
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)
现在你的工作是根据 beta(1)
、beta(2)
和 beta(3)
求解 a
、b
和 c
你可以在纸上做。
我有这样的数据:
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]
我希望 y
是 x
的函数,其中 y = a(0.01 − b*n^−cx).
找到适合数据的系数 a
、b
和 c
的最佳组合的最佳和最简单的计算方法是什么?
我可以使用 Octave 吗?
你的函数
y = a(0.01 − b*n−cx)
是一个非常特殊的形式,有 4 个未知数。为了从你的观察列表中估计你的参数,我建议你简化它
y = β1 + β2β3x
这成为我们的 objective 函数,我们可以使用普通最小二乘法求解一组良好的贝塔值。
在默认的 Matlab 中,您可以使用 fminsearch
to find these β parameters (lets call it our parameter vector, β), and then you can use simple algebra to get back to your a
, b
, c
and n
(assuming you know either b
or n
upfront). In Octave I'm sure you can find an equivalent function, I would start by looking in here: http://octave.sourceforge.net/optim/index.html。
我们将调用 fminsearch
,但我们需要以某种方式传递您的观察结果(即 x
和 y
),我们将使用匿名函数来实现,所以就像文档中的示例 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.
我们这样定义 objective 函数:
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)
现在你的工作是根据 beta(1)
、beta(2)
和 beta(3)
求解 a
、b
和 c
你可以在纸上做。