home *** CD-ROM | disk | FTP | other *** search
- stextn (n,c,d,x,y,aa,bb,rate)
-
- /*this subroutine determines the intercept, slope and growth rate*/
- /*of an exponential trend of the type y = aa*(c**(aa*x)).*/
-
- int n;
- float c,d,x[],y[],*aa,*bb,*rate;
-
- {
-
- int i;
- float sx,sy,sxy,sxx,fn,a,b;
- extern double exp(),log(),pow();
-
- sx = sy = sxy = sxx = 0.;
-
- for (i = 0; i <= n-1; i++)
- {
- if (d == 0)
- y[i] = log(y[i])*0.43429;
- else
- y[i] = log(y[i]);
- sx = sx + x[i];
- sy = sy + y[i];
- sxy = sxy + x[i]*y[i];
- sxx = sxx + x[i]*x[i];
- }
-
- fn = n;
- b = (fn*sxy - sx*sy)/(fn*sxx - sx*sx);
- a = (sy*sxx - sx*sxy)/(fn*sxx - sx*sx);
-
- if (d ==0)
- {
- *aa = pow(10.,a);
- *bb = b/(log(c) * 0.43429);
- }
- else
- {
- *aa = exp(a);
- *bb = b/log(c);
- }
- *rate = pow(c,*bb) - 1.;
-
- }