[General Information]

Function Name=Pulse		; name show up in the select function dialog
Brief Description=Pulse Function(x >= x0 ? y : 0)
Function Type=Built-in		; source type, built-in, user-defined, external dll
Function Form=Expression	; function form;
Function Source=fgroup.Pulse
Number Of Parameters=6
Number Of Independent Variables=1
Number Of Dependent Variables=1


[Fitting Parameters]

Naming Method=user-defined
Names=y0,x0,A,t1,P,t2
Lower bounds=--,--,0.0(X,ON),0.0(X,ON),0.0(X,ON),0.0(X,ON)
Upper bounds=--,--,--,--,--,--
Meanings=offset,center,amplitude,width,power,width


[Independent Variables]

x = 


[Dependent Variables]

y = 


[Constants]


[Formula]
if(x < x0)
	y = 0;
else
	y = y0 + A*(1-exp(-(x-x0)/t1))^P * exp(-(x-x0)/t2);
[Constraints]


[Parameters Initialization]
sort(x_y_curve);
//smooth(x_y_curve, 2);
if(y50(y_data)>y25(y_data)) y0=min(y_data);  // original logic works for most case
if(y50(y_data)<y25(y_data)) y0=max(y_data);

if(y50(y_data)==y25(y_data))  // two points identical then assume it may be a peak in a constant background
y0 = (y_data[0]+ y_data[y_data.GetSize()-1])/2.0; //  for a positive t1 t2  asymptotically, the last or the first element can be treated as baseline

A = area( x_y_curve, y0 );
if ( A > 0 ) x0 = xatymax( x_y_curve );
else x0 = xatymin( x_y_curve );
t1=1.0;
t2=2.0;
P=1.5;



[Initializations]


[After fitting]


[Controls]
General Linear Constraints=Off
Initialization scripts=Off
Scripts After fitting=Off
Duplicate Offset=2
Duplicate Unit=5
Peak Center=2
Peak Width=4
Peak Amplitude=3