Filter löschen
Filter löschen

Merge two equations smoothly

8 Ansichten (letzte 30 Tage)
Rosario Incandela
Rosario Incandela am 16 Dez. 2015
Kommentiert: Shashvat Prakash am 16 Dez. 2015
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)?

Antworten (1)

Shashvat Prakash
Shashvat Prakash am 16 Dez. 2015
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 Kommentar
Shashvat Prakash
Shashvat Prakash am 16 Dez. 2015
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

Melden Sie sich an, um zu kommentieren.

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by