The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum
 Origin Forum
 Making piecewise function fits continuous
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

noldeorigin

USA
2 Posts

Posted - 03/20/2020 :  11:39:09 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): OriginPro 2015
Operating System: Windows 10

I'm using a piecewise non-linear function and the fits are not continuous across the meeting point of the two pieces (z=zc). I had assumed that the fitting algorithm would check for continuity between the pieces.

Is there a way to force continuity? Unfortunately, the functions don't allow for an easy linear constraint to maintain continuity.

Function:
[Formula]
if (z<=zc)
x = x1/(1 + exp(-(z-zc)/L1));
else
x = x2 - x2/(1 + exp(-(z-zc)/L2));

[Constraints]
x2 > x1;
L2 > L1;


Example of resulting fits:



Thanks!

YimingChen

1592 Posts

Posted - 03/20/2020 :  2:30:44 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

By solving the equation fL(zc) = fR(zc) at the boundary, you can solve x1 as a function of x2, L1, L2. Then replace x1 with this expression. (x1 need to be removed from parameter list now). See if that works.

James
Go to Top of Page

noldeorigin

USA
2 Posts

Posted - 03/20/2020 :  3:34:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thank you for your advice.

I accidentally left out part of the formula, which really complicates the problem, the formula should be (where N is a constant):

if (z<=zc)
y1 = x1/(1 + exp(-(z+N-zc)/L1));
else
y2 = x2 - x2/(1 + exp(-(z-N-zc)/L2));

Unfortunately, I don't think that eliminating x1 will help ensure that y1 and y2 will be equal at z=zc.

I'd expect that there would be a way to make sure that piecewise functions are always continuous.

J


quote:
Originally posted by YimingChen

Hi,

By solving the equation fL(zc) = fR(zc) at the boundary, you can solve x1 as a function of x2, L1, L2. Then replace x1 with this expression. (x1 need to be removed from parameter list now). See if that works.

James


Go to Top of Page

YimingChen

1592 Posts

Posted - 03/23/2020 :  1:59:46 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

If you solve the equation at the boundary, you get x1 = x2*exp(N/L2)/(1+exp(N/L2))*(1+exp(-N/L1)), Replace x1 in first equation and then fit. See figure below.


James
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000