curve fitting a custom equation

조회 수: 38 (최근 30일)
Ayushi Sharma
Ayushi Sharma 2021년 7월 15일
편집: Alex Sha 2021년 7월 18일
a*exp(-x/T) +c*(T*(exp(-x/T)-1)+x)
This is the equation i'm trying to fit using the custom fit tool. Since the variable x is both in exponential and linear form, the data isn't really fitting, it's just a straight line. Is there way to fit the data to this equation?
As a side note: how do I view the numerical values instead of scientific ones in curve fitting tool?
Thank you
  댓글 수: 1
Matt J
Matt J 2021년 7월 16일
편집: Matt J 2021년 7월 16일
In the first line of your post, you show the model equation as,
a*exp(-x/T) +c*(T*(exp(-x/T)-1)+x)
However, in your screenshot of the cftool app, the model equation appears instead as,
a*exp(-x*T) +c*(T*(exp(-x/T)-1)+x)
You should edit your post so that we know which version of the equation is the intended one.

댓글을 달려면 로그인하십시오.

채택된 답변

Alex Sha
Alex Sha 2021년 7월 17일
편집: Alex Sha 2021년 7월 18일
Hi, all, as mentioned by Walter Roberson, the resule I provided above is obtained by using 1stOpt, the biggest advantage, for 1stOpt, is that the guessing of initial-start values are no longer needed for curve-fitting, equation-solving or any other optimization problem.
if the model function is: y=a*exp(-x*T) +c*(T*(exp(-x/T)-1)+x), the result is:
Root of Mean Square Error (RMSE): 15155741.0636478
Sum of Squared Residual: 4.59392974376683E15
Correlation Coef. (R): 0.996754359090101
R-Square: 0.993519252365118
Parameter Best Estimate
---------- -------------
a -33754000.9741343
t -1.00000000434611
c -33754006.8543357
Note the value of parameter t: t=-1.00000000434611, if taking t as -1.00, the chart will become:
The Sensitivity analysis of each parameter is as below:
while, if the model function is: y=a*exp(-x/T) +c*(T*(exp(-x/T)-1)+x), the result is:
Root of Mean Square Error (RMSE): 15137803.4043043
Sum of Squared Residual: 4.58306183814736E15
Correlation Coef. (R): 0.996383637725283
R-Square: 0.992780353526669
Parameter Best Estimate
---------- -------------
a -54592643.2783804
t -1.72718663083536
c -31608221.5261319
  댓글 수: 2
Alex Sha
Alex Sha 2021년 7월 17일
The result got by Matt J (as show below) is actually a local solution, not global one.
a =
-6.2820e+07
c =
-2.9980e+07
T =
1.0481e-14
Matt J
Matt J 2021년 7월 17일
편집: Matt J 2021년 7월 17일
The solution I presented below constrained the search to T>=0, so it might be global subject to that constraint.
It's important to notice as well that whether T=-1 or T=0 is taken as the solution, it results in a cancelation of the exponential terms, leaving an essentially linear solution. It makes it seem like either the model was over-parametrized to begin with, or there isn't enough (x,y) data to accurately estimate the exponential terms.

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2021년 7월 15일
You don't need a custom type. Your model is just exp2 but with modified data (x,y-x)
  댓글 수: 11
Walter Roberson
Walter Roberson 2021년 7월 16일
Alex uses a commercial program named 1stOpt from 7d-soft. It costs roughly $2000 for a license. That is, of course, not exactly "cheap"; however, having seen the results Alex has posted on a number of different problems, I would say that if you do curve fitting, that it does a very nice job. I can sometimes improve slightly over the results it gets, but only after at least an hour of work.
Matt J
Matt J 2021년 7월 16일
편집: Matt J 2021년 7월 16일
Thank you so much for your input. I have opted for this method.
@Ayushi Sharma You're welcome, but please Accept-click the answer if you consider the question addressed.
Alex uses a commercial program named 1stOpt from 7d-soft. ... I would say that if you do curve fitting, that it does a very nice job.
However, the fit Alex has shown us is based on an incorrect model equation, because @Ayushi Sharma had a typo in the first line of his post. If we substitute Alex's parameter estimates into the true model, it gives strong disagreement with the data:
load doubt
a=-54592639.7090172;
c=-31608221.6797308;
T=-1.72718650949557;
fun=@(x) a*exp(-x*T) +c*(T*(exp(-x/T)-1)+x);
plot(x,y,'o'); ax=axis;
hold on
plot( x,fun(x));
hold off
axis(ax)
legend('Data','Fit')

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by