필터 지우기
필터 지우기

Merge two equations smoothly

조회 수: 8 (최근 30일)
Rosario Incandela
Rosario Incandela 2015년 12월 16일
댓글: Shashvat Prakash 2015년 12월 16일
Hello everybody, My problem is the following: I need to fit some data that have different Mathematical behaviors: in the first region the points follow an exponential curve, in the second region they follow a quadratic curve. I can fit the two regions with different fitting functions, but how can I merge the two functions in order to have a smooth transition (at least the first two derivatives should be continuous)?

답변 (1개)

Shashvat Prakash
Shashvat Prakash 2015년 12월 16일
Try functions like pchip or spline. This does a piecewise polynomial approximation that goes through all the data. If you want instead a smooth function that approximates your data by combining two sub-functions, I would try a function of the following form
f(x) = f1(x)*(sfn(x-xh)) + f2(x)*(1-sfn(x-xh))
Here, f1 is your exponential, f2 is the polynomial approx., and sfn is the as yet undetermined smoothing function which will smoothly vary from 1 to 0 at the specified xh.
The trick now is to find a suitable smoothing fn that transition from 0 to 1 or vice versa. 1-exp(-x/tau) is a smooth transition from 0 to 1, but only for x>0 -- you can limit this using a max() function. Tau sets the rate of transition. You can also try a simple ramp-in function: sfh=k*(x-xh)-- once again you have to bound it between 0 and 1: sfh=max(min(k*(x-xh),1),0). If you want to get fancy, try a second order equation with initial and final slope=0.
  댓글 수: 1
Shashvat Prakash
Shashvat Prakash 2015년 12월 16일
I completely forgot about the continuous second derivative. I apologize. For sfh, I would find a function that has first derivative zero at + and - infinity, so sfh'(-inf)= sfh'(inf) = 0, and sfh(0)=.5, sfh(-inf)=0, and sfh(inf)=1. A prime example is the logistic function: sig(x)=1/(1+exp(-x)).
https://en.wikipedia.org/wiki/Logistic_regression
https://upload.wikimedia.org/wikipedia/commons/8/88/Logistic-curve.svg

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

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by