[GENERAL INFORMATION]
Function Name=Weibull3
Brief Description=Weibull peak function
Function Source=fgroup.Weibull3
Function Type=Built-in
Function Form=Expression
Number Of Parameters=5
Number Of Independent Variables=1
Number Of Dependent Variables=1


[FITTING PARAMETERS]
Naming Method=User-Defined
Names=y0,xc,A,w1,w2
Meanings=offset,center,amplitude,width,width
Lower Bounds=--,--,--,0.0(X,ON),0.0(X,ON)
Upper Bounds=--,--,--,--,--
Number Of Significant Digits=


[FORMULA]

S=(x-xc)/w1 + ((w2-1)/w2)^(1/w2)
y = y0+A*((w2-1)/w2)^((1-w2)/w2) * S^(w2-1) * exp(-s^w2+(w2-1)/w2)


[CONSTRAINTS]


[Parameters Initialization]
sort(x_y_curve);
smooth(x_y_curve);
y0 = yatxmax( x_y_curve );
int i1,i2,j1,j2,j3;
int uindex=x_y_curve.GetUpperIndex();
int lindex=x_y_curve.GetLowerIndex();
if ( fabs(y0-yatxmin(x_y_curve)) < 0.2*(max(y_data)-min(y_data)) )
{ // case w2 even:
	if(xatymax(x_y_curve)>xatymin(x_y_curve))
	{
		xc = xatymax(x_y_curve);
		A = max( y_data ) - y0;
	}
	else
	{
		xc = xatymin(x_y_curve);
		A = min( y_data ) - y0;
	}
	for(i1=lindex;i1<uindex-1;i1++)
		if((y_data[i1]-y0-A/5.0)*(y_data[i1+1]-y0-A/5.0)<0) break;
	for(i2=Data_list(xc,&x_data);i2<uindex-1;i2++)
		if((y_data[i2]-y0+A/5.0)*(y_data[i2+1]-y0-A/5.0)<0) break;
	w1=x_data[i2]-x_data[i1]; // x width at y0+A/5.0
	int iw2;
	iw2=1.0/sqrt(1-fabs(xatymax(x_y_curve)-xatymin(x_y_curve))/(2*(int)(w1+1)));
	if(iw2%2)  w2=iw2+1; // make it even
	else   	   w2=iw2;
}
else
{ // case w2 odd:
	for(j1=lindex+1;j1<uindex-1;j1++)
		if(fabs(y_data[j1]-y0) < 0.001) break; // turnning point
	// compute A and xc
	for(A=0,xc=x_data[j1],j2=j1;j2<uindex;j2++)
		if( fabs(A) < fabs(y_data[j2]-y0) )  {
			xc = x_data[j2];
			A = y_data[j2] - y0;
		}
	// compute x width at y0+A/5.0
	for(i1=j1;i1<uindex-1;i1++)
		if((y_data[i1]-y0-A/5.0)*(y_data[i1+1]-y0-A/5.0)<0) break;
	for(i2=Data_list(xc,&x_data);i2<uindex-1;i2++)
		if((y_data[i2]-y0+A/5.0)*(y_data[i2+1]-y0-A/5.0)<0) break;
	w1=x_data[i2]-x_data[i1]; // x width at y0+A/5.0
	w2=3.0; // just let it be 3.0
}

[CONSTANTS]


[INITIALIZATIONS]



[AFTER FITTING]



[INDEPENDENT VARIABLES]
x=


[DEPENDENT VARIABLES]
y=


[CONTROLS]
General Linear Constraints=Off
Initialization Scripts=Off
Scripts After Fitting=Off
Number Of Duplicates=0
Duplicate Offset=2
Duplicate Unit=4



