没有“曲线拟合"工具箱的指数曲线拟合? [英] Exponential curve fitting without the Curve Fitting toolbox?

查看:135
本文介绍了没有“曲线拟合"工具箱的指数曲线拟合?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些数据点需要拟合以下形式的指数曲线

I have some data points to which I need to fit an exponential curve of the form

y = B * exp(A/x)

(无需曲线拟合工具箱的帮助.)

到目前为止,我尝试通过应用对数来线性化模型,结果是

What I have tried so far to linearize the model by applying log, which results in

log(y/B) = A/x

log(y) = A/x + log(B)

然后我可以将其写成表格

I can then write it in the form

Y = AX + B

现在,如果我忽略了B,那么我可以通过

Now, if I neglect B, then I am able to solve it with

A = pseudoinverse (X) * Y

但是我坚持使用B ...

but I am stuck with values of B...

推荐答案

拟合形式的曲线

y = b * exp(a / x)

在最小二乘意义上

到某些数据点(xi, yi)是困难的.您不能为此使用线性最小二乘,因为模型参数(ab)在方程中不会以仿射的方式出现.除非您准备使用某种非线性最小二乘法,否则另一种方法是修改优化问题,以便可以使用线性最小二乘法来解决修改后的问题 (此过程有时称为数据线性化").让我们开始吧.

to some data points (xi, yi) in the least-squares sense is difficult. You cannot use linear least-squares for that, because the model parameters (a and b) do not appear in an affine manner in the equation. Unless you're ready to use some nonlinear-least-squares method, an alternative approach is to modify the optimization problem so that the modified problem can be solved using linear least squares (this process is sometimes called "data linearization"). Let's do that.

byi为正的假设下,您可以将自然对数应用于等式的两边:

Under the assumption that b and the yi's be positive, you can apply the natural logarithm to both sides of the equations:

log(y) = log(b) + a / x

a / x + log(b) = log(y)

通过引入定义为log(b)的新参数b2,很明显,参数ab2在新等式中以线性(仿射,实际上)方式出现:

By introducing a new parameter b2, defined as log(b), it becomes evident that parameters a and b2 appear in a linear (affine, really) manner in the new equation:

a / x + b2 = log(y)

因此,您可以使用最小二乘法计算这些参数的最佳值;您所要做的就是构建正确的线性系统,然后使用MATLAB的反斜杠运算符对其求解:

Therefore, you can compute the optimal values of those parameters using least squares; all you have left to do is construct the right linear system and then solve it using MATLAB's backslash operator:

A = [1 ./ x, ones(size(x))];
B = log(y);
params_ls = A \ B;

(我假设xy是列向量,).

(I'm assuming x and y are column vectors, here.)

然后,修改后的问题的最优值(在最小二乘意义上)由下式给出:

Then, the optimal values (in the least-squares sense) for the modified problem are given by:

a_ls = params_ls(1);
b_ls = exp(params_ls(2));

尽管这些值通常对于原始问题不是最佳的,但在实践中它们通常足够好".如果需要,您可以始终将它们用作某些迭代的非线性最小二乘方法的初始猜测.

Although those values are not, in general, optimal for the original problem, they are often "good enough" in practice. If needed, you can always use them as initial guesses for some iterative nonlinear-least-squares method.

这篇关于没有“曲线拟合"工具箱的指数曲线拟合?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆