[General Information]

Function Name=HyperbolaGen		; name show up in the select function dialog
Brief Description=Generalized Hyperbola function
Function Type=Built-in		; source type, built-in, user-defined, external dll
Function Form=Expression	; function form;
Function Source=fgroup.HyperbolaGen
Number Of Parameters=4
Number Of Independent Variables=1
Number Of Dependent Variables=1


[Fitting Parameters]

Naming Method=user-defined
Names=a,b,c,d
Lower bounds=--,--,--,--
Upper bounds=--,--,--,--
Meanings=coefficient,coefficient,coefficient,coefficient

[Independent Variables]

x = 


[Dependent Variables]

y = 


[Constants]


[Formula]

y = a - b/(1 + c*x)^(1/d)

[Constraints]

[Parameters Initialization]
sort(x_y_curve);
//smooth(x_y_curve, 2);
if( fabs(xatymax(x_y_curve)-xatymin(x_y_curve))<(max(x_data)-min(x_data))*2/3 ) {
   a=(yatxmin(x_y_curve) + yatxmax(x_y_curve))/2.0;
   c=-1.0/xatymin(x_y_curve);
}
else {
   double dy1=Curve_yfromX(&x_y_curve,0.9*min(x_data)+0.1*max(x_data))-yatxmin(x_y_curve);
   double dy2=yatxmax(x_y_curve)-Curve_yfromX(&x_y_curve,0.1*min(x_data)+0.9*max(x_data));
   if( fabs(dy1)<fabs(dy2) ) {
      a=yatxmin(x_y_curve);
      c=-1.0/max(x_data);
     }
   else {
      a=yatxmax(x_y_curve);
      c=-1.0/min(x_data);
     }
      
}
if(c<0) c=-c;
double x1=0.8*min(x_data)+0.2*max(x_data);
double y1=Curve_yfromX(&x_y_curve,x1);
double x2=0.1*min(x_data)+0.9*max(x_data);
double y2=Curve_yfromX(&x_y_curve,x2);
d=(ln(fabs(1+c*x1))-ln(fabs(1+c*x2)))/(ln(fabs(a-y2))-ln(fabs(a-y1)));
b=fabs(a-y1)*pow(fabs(1+c*x1),d);


[Initializations]


[After fitting]


[Controls]
General Linear Constraints=Off
Initialization scripts=Off
Scripts After fitting=Off
