如何找到可能的指数近似系数 [英] 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).
and I want y
to be a function of x
with y = a(0.01 − b*n^−cx).
找到适合数据的系数a
,b
和c
的最佳组合的最佳和最简单的计算方法是什么?
What is the best and easiest computational approach to find the best combination of the coefficients a
, b
and c
that fit to the data?
我可以使用八度音阶吗?
Can I use Octave?
推荐答案
您的函数
y = a(0.01 − b * n -cx )
是一种非常具体的形式,有4个未知数.为了从观测列表中估算参数,我建议您对其进行简化
is in quite a specific form with 4 unknowns. In order to estimate your parameters from your list of observations I would recommend that you simplify it
y =β 1 +β 2 β 3 x
y = β1 + β2β3x
这成为我们的目标函数,我们可以使用普通的最小二乘法来求解一组好的beta.
This becomes our objective function and we can use ordinary least squares to solve for a good set of betas.
在默认的Matlab中,您可以使用 fminsearch
来找到这些β参数(我们称其为参数向量 β ),然后可以使用简单的代数返回到a
,b
,c
和n
(假设您预先知道b
或n
).在Octave中,我确定您可以找到等效的函数,请从以下位置开始: http: //octave.sourceforge.net/optim/index.html .
In default Matlab you could use 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:
We're going to call fminsearch
, but we need to somehow pass in your observations (i.e. x
and y
) and we will do that using anonymous functions, so like example 2 from the docs:
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.
我们这样定义目标函数:
And we define our objective function like this:
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
.
Now it's your job to solve for a
, b
and c
in terms of beta(1)
, beta(2)
and beta(3)
which you can do on paper.
这篇关于如何找到可能的指数近似系数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!