How to evaluate a curve at infinite points inside it's upper and lower bounds.

조회 수: 5 (최근 30일)
Please see attached dataset and image. I want to be able to evaulate infinite points along the interpolated curve that these points create. Is there a way to do this? I've tried using the cftool, but haven't come up with anything useful. It does not fit an exponential or gaussian curve well enough for what I need. I'm probably missing something very basic. Thank you for taking a look!!!
curves.png
  댓글 수: 2
John D'Errico
John D'Errico 2020년 2월 4일
You want to evaluate the curve at infinitely many points? Do you have a long time to wait? Infinity is a long way away, even if your computer is fast.
Your curves do not appear to fit well down in the lower tail, but that is reasonable, given that you are plotting it on a LOG scale. When data falls over multiple orders of magnitude, it is common to expect an unweighted standard fit to fit poorly at one end.
Perhaps, by the phrase "infinite points" you are hoping to find a good prediction for an asymptote?
What does "infinite points" mean to you? Please explain more clearly.
Walter Roberson
Walter Roberson 2020년 2월 4일
편집: Walter Roberson 2020년 2월 4일
fit() creates a fit object that you can use like a function to call on a value to predict the output there, so
fitobj = fit(....);
fitobj(inf)
In some cases you might have to extract the formula and substitute in symbolic variables for the parameters, and then use symbolic limit() at infinity

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

채택된 답변

Patrick Lokken
Patrick Lokken 2020년 2월 7일
Thanks for the responses, but I don't think they apply to what I'm trying to do. I found interp1(), and it's exactly what I need.
With interp1(), I am able to evaluate anywhere along/between the data points as needed. It gets hairy quickly when extrapolating, but that's alright in my application.
Thanks, again.
  댓글 수: 3
Patrick Lokken
Patrick Lokken 2020년 2월 7일
Your tool looks impressive, but from what I can tell, it requires toolboxes which I don't have, so it does me no good. In my particular case, your solution is also squashing a bug with a sledge hammer (figureatively speaking, of course). I appreciate you're willingness to help, and your SLM tool looks incredibly helpful in the right application.
John D'Errico
John D'Errico 2020년 2월 7일
The problem is, if you tell people that interp1 can solve this, then you will lead them to the wrong solution much of the time. Accepting your own answer here implies it is the right solution. And we have not even agreed on that as correct. You CAN use interp1 to interpolate a curve like that, as long as you do not wish to do any smoothing, AND as long as you use either the linear option or the pchip option to interp1, it will work acceptably. However, even attempting to extrapolate a pchip interpolant can be a risky idea, and you talk about that too. Extrapolating splines (which includes pchip in this respect) is rarely safe, unless you have constructed the spline in an intelligent way, and you know how to extrapolate them safely.
Novice users will then try to use a spline to interpolate (because they want a nice smooth result), and then their next ansguished question will be essentially "Why does interp1 do insane things?"
So by accepting your own answer without actually understanding the implications thereof, without really understanding what you are doing, you create misinformation, and you WILL lead at least some people into the wrong conclusions, because they believe you.
I'm, sorry, but it is possible that you are trying to squash a bug with a screwdriver. Yes, interp1 CAN work, as long as you know how to use it properly.

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

추가 답변 (1개)

John D'Errico
John D'Errico 2020년 2월 4일
편집: John D'Errico 2020년 2월 4일
If I plot your data, it it far too highly nonlinear to use any sort of a fit to the data directly. But plotted on log-log axes, we see:
loglog(x,y,'.')
The solution is to log your data, then model that. rather than bother to find a model that seems reasonable for this, I'll just use my SLM toolbox.
slm = slmengine(log(x),log(y),'knots',10,'decreasing','on','rightslope',0,'plot','on')
Can you predict a value at any point for , in the domain of your data? Of course. For example, at x=1000...
xhat = 1000;
yhat = exp(slmeval(log(xhat),slm))
yhat =
0.0625068383912338
The asymptote at the right end is
exp(slmeval(log(max(x)),slm))
ans =
0.0158793038009348
Works fine. Find SLM on the File Exchange.

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by