#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 1 (of 4)."
# Contents:  ./Doc ./Doc/Input.doc ./Ldh ./Ldh/ldhfit.dat ./Lib
#   ./Lib/Makefile ./Lib/simpdefs.h ./Line ./Line/linefit.c
#   ./Line/linefit.dat ./Line/linefit.test1 ./Line/linefit.test2
#   ./Makefile ./README ./README.mmfit ./README.probset ./assign
#   ./assign/dataset1 ./assign/dataset1.out ./assign/dataset2
#   ./assign/dataset2.out ./assign/dataset3.out ./assign/dataset4.out
#   ./mmfit ./mmfit/Makefile ./mmfit/data.template ./mmfit/mmfit.c
#   ./mmfit/recipfit.dat MANIFEST
# Wrapped by local@rupley on Wed Nov 21 00:30:36 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test ! -d './Doc' ; then
    echo shar: Creating directory \"'./Doc'\"
    mkdir './Doc'
fi
if test -f './Doc/Input.doc' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Doc/Input.doc'\"
else
echo shar: Extracting \"'./Doc/Input.doc'\" \(3408 characters\)
sed "s/^X//" >'./Doc/Input.doc' <<'END_OF_FILE'
X[DEMONSTRATION DATA ENTRY FILE  -  REPLACE THIS LINE BY ONE-LINE TITLE]
X 
X
nvert= (ENTER-VALUE-HERE)	nparm= (ENTER-VALUE-HERE)
X
ndata= (ENTER-VALUE-HERE)	ndatval= (ENTER-VALUE-HERE)
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-8
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X
X[REPLACE THIS LINE BY NVERT SETS OF NPARM VALUES]
X 
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X[REPLACE THIS LINE BY NDATA SETS OF NDATVAL VALUES]
X
X
X-----------------------end of data-------------------------------
X
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3408 -ne `wc -c <'./Doc/Input.doc'`; then
    echo shar: \"'./Doc/Input.doc'\" unpacked with wrong size!
fi
# end of './Doc/Input.doc'
fi
if test ! -d './Ldh' ; then
    echo shar: Creating directory \"'./Ldh'\"
    mkdir './Ldh'
fi
if test -f './Ldh/ldhfit.dat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Ldh/ldhfit.dat'\"
else
echo shar: Extracting \"'./Ldh/ldhfit.dat'\" \(1915 characters\)
sed "s/^X//" >'./Ldh/ldhfit.dat' <<'END_OF_FILE'
wednesday 1989, group 3, soaring bear and julianne ruterman
X 
nvert= 7		nparm= 7
X
ndata(ENTER-VALUE-HERE)= 28			ndatval= 6
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-8
X
prt_cycle= 30		quad_test= 30
X 
starting-simplex[nvert][nparm=V,KmA,KmB,KmAB,KmPQ,1/K(I,B),small]= 
X1       .001    .01     .001    .001    1E-6    1E-10 
X10      .001    .01     .001    .001    1E-6    1E-10 
X1       .1      .01     .001    .001    1E-6    1E-10 
X1       .001    1       .001    .001    1E-6    1E-10 
X1       .001    .01     .1      .001    1E-6    1E-10 
X1       .001    .01     .001    .1      1E-6    1E-10 
X1       .001    .01     .001    .001    1E-2    1E-10 
X 
data[ndata][y,yc,w,a,b,p](ENTER-THE-FIRST-COLUMN-OF-VO-VALUES)= 
X.024   0       1       .011    .15     0 
X.025   0       0       .015    .15     0 
X.036   0       1       .022    .15     0 
X.040   0       1       .035    .15     0 
X
X.034   0       1       .011    .22     0 
X.036   0       1       .015    .22     0 
X.043   0       1       .022    .22     0 
X.052   0       1       .035    .22     0 
X
X.039   0       1       .011    .35     0 
X.045   0       1       .015    .35     0 
X.054   0       1       .022    .35     0 
X.067   0       1       .035    .35     0 
X
X.046   0       1       .011    .70     0 
X.056   0       1       .015    .70     0 
X.065   0       1       .022    .70     0 
X.087   0       1       .035    .70     0 
X
X.020   0       0       .011    .15     0 
X.043   0       1       .035    .15     0 
X.043   0       1       .011    .70     0 
X.078   0       1       .035    .70     0 
X
X.022   0       1       .035    .15     150 
X.020   0       1       .035    .22     150 
X.030   0       1       .035    .35     150 
X.041   0       1       .035    .70     150 
X
X.021   0       1       .035    .15     150 
X.048   0       1       .035    .70     150 
X
X.052   0       0       .035    .15     0 
X.035   0       0       .011    .70     0 
END_OF_FILE
if test 1915 -ne `wc -c <'./Ldh/ldhfit.dat'`; then
    echo shar: \"'./Ldh/ldhfit.dat'\" unpacked with wrong size!
fi
# end of './Ldh/ldhfit.dat'
fi
if test ! -d './Lib' ; then
    echo shar: Creating directory \"'./Lib'\"
    mkdir './Lib'
fi
if test -f './Lib/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Lib/Makefile'\"
else
echo shar: Extracting \"'./Lib/Makefile'\" \(500 characters\)
sed "s/^X//" >'./Lib/Makefile' <<'END_OF_FILE'
P=		lp -onroff -olq
X
CFILES=\
X		simpinput.c \
X		simpmain.c \
X		simpfit.c \
X		simpdev.c \
X		simplib0.c 
X
OBJECTS=\
X		simpinput.o \
X		simpmain.o \
X		simpfit.o \
X		simpdev.o \
X		simplib0.o 
X
LINT=		lint -uvx 
X
LIBES=		-lm
X
CFLAGS=		-O 
X
all:		$(OBJECTS)
X
simpinput.o:	simpinput.c simpdefs.h
X
simpmain.o:	simpmain.c simpdefs.h
X
simpfit.o:	simpfit.c simpdefs.h
X
simpdev.o:	simpdev.c simpdefs.h
X
simplib0.o:	simplib0.c simpdefs.h
X
clean:
X		rm *.o
X
print:
X		pr $(CFILES) | $(P)
X
lint:
X		$(LINT) $(CFILES) 
X
END_OF_FILE
if test 500 -ne `wc -c <'./Lib/Makefile'`; then
    echo shar: \"'./Lib/Makefile'\" unpacked with wrong size!
fi
# end of './Lib/Makefile'
fi
if test -f './Lib/simpdefs.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Lib/simpdefs.h'\"
else
echo shar: Extracting \"'./Lib/simpdefs.h'\" \(1935 characters\)
sed "s/^X//" >'./Lib/simpdefs.h' <<'END_OF_FILE'
X/* SIMPDEFS.C */
X/*- 
defines, includes, structures, externals
common to most or all files for simplex fitting
X
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#include <stdio.h>
X#include <math.h>
X#include <ctype.h>
X
X#define ERROR		-1
X#define OK		0
X#define TRUE		1
X#define FALSE		0
X
X#define MAX(X,Y)	((X) >  (Y) ?  (X) : (Y))
X#define MIN(X,Y)	((X) <= (Y) ?  (X) : (Y))
X#define ABS(X)		((X) <   0  ? -(X) : (X))
X
X#define NPARM		10	/* limit no. parms in pstruct */
X#define NDATVAL		10	/* limit no. indep. variables = NDATVAL - 3 */
X#define NDATA		300	/* limit no. data pts */
X#define NVERT		(NPARM + 1)
X
struct dat {
X	double datval[NDATVAL] ;
X} ;
struct pstruct {
X	double val ;
X	double parm[NPARM] ;
X}  ;
struct qstruct {
X	int parmndx[NPARM] ;
X	double q[NPARM] ;
X	double yplus[NPARM] ;
X	double yminus[NPARM] ;
X	double a[NPARM] ;
X	double bdiag[NPARM] ;
X	double inv_bdiag[NPARM] ;
X	double std_dev[NPARM] ;
X}  ;
X
X#ifdef XXXXFIT
X				/* EXTERNAL DEFINITIONS */
struct dat data[NDATA] ;
struct pstruct p[NVERT] ;
struct pstruct pcent ;
struct pstruct *p_p[NVERT] ;
struct pstruct pmin ;
struct qstruct q ;
X
double bounds[2][NPARM] ;
double qmat[NPARM][NPARM] ;
double mean_func, rms_func, test, rms_data ;
double yzero, ymin, ypmin, mse ;
double quad_test, exit_test ;
int iter, maxiter, nparm, nvert, ndata, maxquad_skip, prt_cycle, ndatval ;
int nfree ;
char title[80] ;
X
X#else
X				/* EXTERNAL DECLARATIONS */
extern struct dat data[NDATA] ;
extern struct pstruct p[NVERT] ;
extern struct pstruct pcent ;
extern struct pstruct *p_p[NVERT] ;
extern struct pstruct pmin ;
extern struct qstruct q ;
X
double bounds[2][NPARM] ;
extern double qmat[NPARM][NPARM] ;
extern double mean_func, rms_func, test, rms_data ;
extern double yzero, ymin, ypmin, mse ;
extern double quad_test, exit_test ;
extern int iter, maxiter, nparm, nvert, ndata, maxquad_skip, 
X	prt_cycle, ndatval ;
extern int nfree ;
extern char title[80] ;
X
X#endif
X
END_OF_FILE
if test 1935 -ne `wc -c <'./Lib/simpdefs.h'`; then
    echo shar: \"'./Lib/simpdefs.h'\" unpacked with wrong size!
fi
# end of './Lib/simpdefs.h'
fi
if test ! -d './Line' ; then
    echo shar: Creating directory \"'./Line'\"
    mkdir './Line'
fi
if test -f './Line/linefit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Line/linefit.c'\"
else
echo shar: Extracting \"'./Line/linefit.c'\" \(3482 characters\)
sed "s/^X//" >'./Line/linefit.c' <<'END_OF_FILE'
X/* LINEFIT.C */
X/*-
VERSION OF XXXXFIT, for:
X  
nonlinear least squares fit by simplex minimizaton (Nelder-Mead algorithm).
X  
test:
X	fit of the linear function:     y  =  a  +  b * x
X	to data that can be reduced by hand.
X */
X/*-
contents of the XXXXFIT module  =  
declarations and routines for simplex fitting special to function to be fit
X(no other functions/files need to be rewritten or adapted for a new model):
X  
X	mnemonic defines for members of data and parameter structures
X  
X	function for calculation of dependent variable and
X		weighted sum of residuals squared		= func()
X  
X	print of <data> records					= fdatprint()
X  
X	additional display called by fdatprint(), 
X		specially written for this model 		= fpointprint()
X  
X	customizable display called by <simpfit()>, 
X		following the output tracking each cycle
X		of minimization					= fspecial()
X  
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#define XXXXFIT
X
X#include "simpdefs.h"		/* externals are read from <simpdefs> */
X
X/* DEFINES SPECIAL TO FITTING FUNCTION */
X
X#define Y	0		/* defines for elements of struct dat */
X#define YC	1		/* (mnemonic) */
X#define W	2
X#define X	3
X
X#define A	0		/* defines for elements of struct pstruct */
X#define B	1		/* (mnemonic) */
X
X/*-
XFUNC
X	CALCULATION OF LEAST SQUARES FUNCTION
X	CODED ACCORDING TO MODEL BEING FIT
X	IT SHOULD BE EFFICIENT
X	DURING THE FIT, TIME IS MOSTLY SPENT HERE
X*/
X
int
func(pnam)
X	struct pstruct *pnam;
X{
X	register int    n;
X
X	extern struct dat data[];
X	extern int      nparm;
X	extern int      ndata;
X
X	/*
X	 * here set/test bounds on parms...not applicable to linefit 
X	 */
X
X	pnam->val = 0;
X	for (n = 0; n < ndata; n++) {
X		/* evaluation of dependent variable */
X		data[n].datval[YC] = pnam->parm[A] +
X			pnam->parm[B] * data[n].datval[X];
X		/* evaluation of weighted sum of residuals squared */
X		pnam->val = pnam->val
X			+ (data[n].datval[Y] - data[n].datval[YC])
X			* (data[n].datval[Y] - data[n].datval[YC])
X			* data[n].datval[W]
X			* data[n].datval[W];
X	}
X	return (OK);
X}				/* END OF FUNC        			 */
X
X/*-
XFDATPRINT
X	PRINT DATA AND COMPARE WITH CALCULATED VALUES
X	CODED ACCORDING TO MODEL AND DATA
X*/
X
void
fdatprint(fptr)
X	FILE           *fptr;
X{
X	register int    j;
X
X	extern void     fpointprint();
X
X	extern int      iter, ndata, maxiter;
X	extern struct dat data[];
X	extern char     title[];
X
X	fprintf(fptr, "\1\f\n%-s\n\niteration number %d\n\n", title, iter);
X	fprintf(fptr,
X		"        yobs   ycalc   del-y  weight       x\n");
X	for (j = 0; j < ndata; j++)
X		fprintf(fptr,
X			"%4d %7.3f %7.3f %7.3f %7.3f %10.5f\n",
X			(j + 1), data[j].datval[Y], data[j].datval[YC],
X			(data[j].datval[Y] - data[j].datval[YC]),
X			data[j].datval[W], data[j].datval[X]);
X
X	if (maxiter != 0)
X		fpointprint(fptr);
X}				/* END OF FDATPRINT			 */
X
X/*-
XFPOINTPRINT
X	CODE FOR SPECIAL OUTPUT, IF ANY
X*/
X
void
fpointprint(fptr)
X	FILE           *fptr;
X{
X}				/* END OF FPOINTPRINT			 */
X
X
X/*-
XFSPECIAL
X	DISPLAY ADDITIONAL INFORMATION DURING
X	TRACKING OF MINIMIZATION, IN SIMPFIT()
X*/
X
void
fspecial(fptr)
X	FILE           *fptr;
X{
X	register        j;
X
X	extern int      maxiter;
X	extern double   ypmin, yzero, quad_test;
X
X	if (ypmin > 0.99E38) {
X		fprintf(fptr, "y-pmin error");
X		for (j = 0; j < nvert; j++)
X			if (pmin.parm[j] < 0)
X				fprintf(fptr, " (parm(%d) < 0)", j);
X	} else if (ypmin > yzero)
X		fprintf(fptr, "y-pmin > yzero");
X
X	fprintf(fptr, "    next_prt= %d  next_quad= %7.2e\n",
X		maxiter, quad_test);
X
X	return;
X}				/* END OF FSPECIAL			 */
END_OF_FILE
if test 3482 -ne `wc -c <'./Line/linefit.c'`; then
    echo shar: \"'./Line/linefit.c'\" unpacked with wrong size!
fi
# end of './Line/linefit.c'
fi
if test -f './Line/linefit.dat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Line/linefit.dat'\"
else
echo shar: Extracting \"'./Line/linefit.dat'\" \(530 characters\)
sed "s/^X//" >'./Line/linefit.dat' <<'END_OF_FILE'
linear least squares on set of data previously done by hand
X 
nvert= 3		nparm= 2
X
ndata= 11		ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
simplex[nvert][nparm=a,b]= 
X-1e-6	-1e-6
X1e6	-1e-6
X-1e-6	1e6
X
X 
data[ndata][y,yc,w,x]= 
X3.1	0	1	1
X4.9	0	1	2
X7.3	0	1	3
X8.7	0	1	4
X10.7	0	1	5 
X13.0	0	1	6 
X15.3	0	1	7 
X17.3	0	1	8 
X18.7	0	1	9 
X21.1	0	1	10
X22.9	0	1	11
X
comment:
X
hand calculation gives intercept a = 1.01090909     std devn = .1641115
X
X			   slope b = 1.99818182     std devn = .02419692
X
END_OF_FILE
if test 530 -ne `wc -c <'./Line/linefit.dat'`; then
    echo shar: \"'./Line/linefit.dat'\" unpacked with wrong size!
fi
# end of './Line/linefit.dat'
fi
if test -f './Line/linefit.test1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Line/linefit.test1'\"
else
echo shar: Extracting \"'./Line/linefit.test1'\" \(1896 characters\)
sed "s/^X//" >'./Line/linefit.test1' <<'END_OF_FILE'
X
linear least squares on set of data previously done by hand
X
summary of simplex fitting results:
iteration number 84
X
simplex:
vertex = 0   function value = 5.79636363637241e-01
X   1.0109088967e+00   1.9981818829e+00
vertex = 1   function value = 5.79636363636699e-01
X   1.0109093420e+00   1.9981818045e+00
vertex = 2   function value = 5.79636363636365e-01
X   1.0109090909e+00   1.9981818182e+00
X
centroid:
function value = 5.79636363636558e-01
X   1.0109091099e+00   1.9981818352e+00
mean=5.79636363636768e-01 rms=3.60999676637164e-13 test=6.22803708125162e-13
root mean square weighted error of best fit to data = 2.53779511395307e-01
X
X
linear least squares on set of data previously done by hand
X
iteration number 84
X
X        yobs   ycalc   del-y  weight       x
X   1   3.100   3.009   0.091   1.000    1.00000
X   2   4.900   5.007  -0.107   1.000    2.00000
X   3   7.300   7.005   0.295   1.000    3.00000
X   4   8.700   9.004  -0.304   1.000    4.00000
X   5  10.700  11.002  -0.302   1.000    5.00000
X   6  13.000  13.000   0.000   1.000    6.00000
X   7  15.300  14.998   0.302   1.000    7.00000
X   8  17.300  16.996   0.304   1.000    8.00000
X   9  18.700  18.995  -0.295   1.000    9.00000
X  10  21.100  20.993   0.107   1.000   10.00000
X  11  22.900  22.991  -0.091   1.000   11.00000
X
linear least squares on set of data previously done by hand
X
summary of results of quadratic fit
iteration number 84
X
mean=5.79636363636768e-01 rms=3.60999676637164e-13 test=6.22803708125162e-13
X
mse    = 6.44040404040405e-02   rms weighted error = 2.53779511395307e-01
X
yzero  = 5.79636363636365e-01
ymin   = 5.79636363636365e-01
y-pmin = 5.79636363636364e-01
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.48444727177e-07 1.01090909091e+00 1.01090909152e+00 1.62447392041e-01
X  1   1 2.61436228222e-08 1.99818181818e+00 1.99818181809e+00 2.38776239771e-02
END_OF_FILE
echo shar: 3 control characters may be missing from \"'./Line/linefit.test1'\"
if test 1896 -ne `wc -c <'./Line/linefit.test1'`; then
    echo shar: \"'./Line/linefit.test1'\" unpacked with wrong size!
fi
# end of './Line/linefit.test1'
fi
if test -f './Line/linefit.test2' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Line/linefit.test2'\"
else
echo shar: Extracting \"'./Line/linefit.test2'\" \(1896 characters\)
sed "s/^X//" >'./Line/linefit.test2' <<'END_OF_FILE'
X
linear least squares on set of data previously done by hand
X
summary of simplex fitting results:
iteration number 84
X
simplex:
vertex = 0   function value = 5.79636363637239e-01
X   1.0109088967e+00   1.9981818829e+00
vertex = 1   function value = 5.79636363636698e-01
X   1.0109093420e+00   1.9981818045e+00
vertex = 2   function value = 5.79636363636364e-01
X   1.0109090909e+00   1.9981818182e+00
X
centroid:
function value = 5.79636363636556e-01
X   1.0109091099e+00   1.9981818352e+00
mean=5.79636363636767e-01 rms=3.60514757554340e-13 test=6.21967116231962e-13
root mean square weighted error of best fit to data = 2.53779511395306e-01
X
X
linear least squares on set of data previously done by hand
X
iteration number 84
X
X        yobs   ycalc   del-y  weight       x
X   1   3.100   3.009   0.091   1.000    1.00000
X   2   4.900   5.007  -0.107   1.000    2.00000
X   3   7.300   7.005   0.295   1.000    3.00000
X   4   8.700   9.004  -0.304   1.000    4.00000
X   5  10.700  11.002  -0.302   1.000    5.00000
X   6  13.000  13.000  -0.000   1.000    6.00000
X   7  15.300  14.998   0.302   1.000    7.00000
X   8  17.300  16.996   0.304   1.000    8.00000
X   9  18.700  18.995  -0.295   1.000    9.00000
X  10  21.100  20.993   0.107   1.000   10.00000
X  11  22.900  22.991  -0.091   1.000   11.00000
X
linear least squares on set of data previously done by hand
X
summary of results of quadratic fit
iteration number 84
X
mean=5.79636363636767e-01 rms=3.60514757554340e-13 test=6.21967116231962e-13
X
mse    = 6.44040404040404e-02   rms weighted error = 2.53779511395306e-01
X
yzero  = 5.79636363636364e-01
ymin   = 5.79636363636364e-01
y-pmin = 5.79636363636364e-01
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.48444727186e-07 1.01090909091e+00 1.01090909093e+00 1.64165872841e-01
X  1   1 2.61436228499e-08 1.99818181818e+00 1.99818181818e+00 2.42045977290e-02
END_OF_FILE
echo shar: 3 control characters may be missing from \"'./Line/linefit.test2'\"
if test 1896 -ne `wc -c <'./Line/linefit.test2'`; then
    echo shar: \"'./Line/linefit.test2'\" unpacked with wrong size!
fi
# end of './Line/linefit.test2'
fi
if test -f './Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./Makefile'\"
else
echo shar: Extracting \"'./Makefile'\" \(3122 characters\)
sed "s/^X//" >'./Makefile' <<'END_OF_FILE'
P=		lp -onroff -olq
X
SIMPDIR=	/usr/local/unix/simplex
DOCDIR=		$(SIMPDIR)/Doc
LDHDIR=		$(SIMPDIR)/Ldh
LINEDIR=	$(SIMPDIR)/Line
LIBDIR=		$(SIMPDIR)/Lib
X
DOCFILES=\
X		$(DOCDIR)/Data_redn.doc \
X		$(DOCDIR)/Input.doc \
X		$(DOCDIR)/Output.doc \
X		$(DOCDIR)/Simplex.doc
X
OTHERFILES=\
X		Makefile \
X		$(LIBDIR)/simpdefs.h \
X		$(LINEDIR)/linefit.c \
X		$(LINEDIR)/linefit.dat \
X		$(LDHDIR)/ldhfit.c \
X		$(LDHDIR)/ldhfit.dat 
X
CFILES=\
X		$(LIBDIR)/simpinput.c \
X		$(LIBDIR)/simpmain.c \
X		$(LIBDIR)/simpfit.c \
X		$(LIBDIR)/simpdev.c \
X		$(LIBDIR)/simplib0.c 
X
OBJECTS=\
X		$(LIBDIR)/simpinput.o \
X		$(LIBDIR)/simpmain.o \
X		$(LIBDIR)/simpfit.o \
X		$(LIBDIR)/simpdev.o \
X		$(LIBDIR)/simplib0.o 
X
LINT=		lint -uvx 
X
LIBES=		-lm
X
CFLAGS=		-O -I$(LIBDIR)
X
all:		$(LINEDIR)/linefit $(LDHDIR)/ldhfit
X
X$(LINEDIR)/linefit:	$(OBJECTS) $(LINEDIR)/linefit.o
X		cc $(CFLAGS) $(OBJECTS) $(LINEDIR)/linefit.o $(LIBES) -o $(LINEDIR)/linefit
X		size $(LINEDIR)/linefit
X
X$(LDHDIR)/ldhfit:		$(OBJECTS) $(LDHDIR)/ldhfit.o
X		cc $(CFLAGS) $(OBJECTS) $(LDHDIR)/ldhfit.o $(LIBES) -o $(LDHDIR)/ldhfit
X		size $(LDHDIR)/ldhfit
X
X$(OBJECTS): 	$(CFILES) $(LIBDIR)/simpdefs.h
X		(cd $(LIBDIR); make)
X
X$(LINEDIR)/linefit.o:	$(LINEDIR)/linefit.c $(LIBDIR)/simpdefs.h
X		(cd $(LINEDIR); cc -c $(CFLAGS) $*.c)
X
X$(LDHDIR)/ldhfit.o:	$(LDHDIR)/ldhfit.c $(LIBDIR)/simpdefs.h
X		(cd $(LDHDIR); cc -c $(CFLAGS) $*.c)
X
clean:
X		-rm $(LINEDIR)/*.o $(LINEDIR)/*.out* $(LINEDIR)/linefit
X		-rm $(LDHDIR)/*.o $(LDHDIR)/*.out* $(LDHDIR)/ldhfit
X
spotless:	clean
X		(cd $(LIBDIR); make clean)
X
install:	$(LDHDIR)/ldhfit
X		strip $(LDHDIR)/ldhfit
X		mv $(LDHDIR)/ldhfit /usr/local/bin/ldhfit
X
manpage:	
X		nroff -man $(DOCDIR)/simplex.1 | col | pg
X
printmanpage:	
X		nroff -man $(DOCDIR)/simplex.1 | $(P)
X
printall:	printmanpage
X		pr $(CFILES) $(OTHERFILES) $(DOCFILES) | $(P)
X
testline:	$(LINEDIR)/linefit.out
X		@echo 
X		@cat $(LINEDIR)/linefit.out
X		@echo 
X		-diff $(LINEDIR)/linefit.test1 $(LINEDIR)/linefit.out
X#		-diff $(LINEDIR)/linefit.test2 $(LINEDIR)/linefit.out
X
X$(LINEDIR)/linefit.out:	$(LINEDIR)/linefit
X		@echo "this may take a while; please be patient...."
X		$(LINEDIR)/linefit -sn -dl $(LINEDIR)/linefit.dat $(LINEDIR)/linefit.out
X
testldh:	$(LDHDIR)/ldhfit.out
X		@echo 
X		@cat $(LDHDIR)/ldhfit.out
X		@echo 
X		-diff $(LDHDIR)/ldhfit.test1 $(LDHDIR)/ldhfit.out
X#		-diff $(LDHDIR)/ldhfit.test2 $(LDHDIR)/ldhfit.out
X
X$(LDHDIR)/ldhfit.out:	$(LDHDIR)/ldhfit
X		@echo "this may take a while; please be patient...."
X		$(LDHDIR)/ldhfit -sn -dl $(LDHDIR)/ldhfit.dat $(LDHDIR)/ldhfit.out 2>/dev/null 1>/dev/null
X
testldhx:	$(LDHDIR)/ldhfit.out $(LDHDIR)/ldhfit.outx
X		-diff $(LDHDIR)/ldhfit.out $(LDHDIR)/ldhfit.outx
X
X$(LDHDIR)/ldhfit.outx:	$(LDHDIR)/ldhfit
X		@echo "this may take a while; please be patient...."
X		cat $(LDHDIR)/ldhfit.dat | \
X			sed 's/\(quad_test= \)[0-9]*/\1 0/' | \
X			$(LDHDIR)/ldhfit -sn -dl -o $(LDHDIR)/ldhfit.outx 2>/dev/null 1>/dev/null
X
lint:
X		$(LINT) $(CFILES) $(LINEDIR)/linefit.c 
X
shar:
X#	cat MANIFEST | sed 1,2d | makekit -pX -s42k >scr
X#	cat MANIFEST | sed 1,2d | makekit -pX -s25k >scr
X	cat MANIFEST | sed 1,2d | makekit  >scr
X	diff scr MANIFEST
X	rm scr
END_OF_FILE
if test 3122 -ne `wc -c <'./Makefile'`; then
    echo shar: \"'./Makefile'\" unpacked with wrong size!
fi
# end of './Makefile'
fi
if test -f './README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./README'\"
else
echo shar: Extracting \"'./README'\" \(2590 characters\)
sed "s/^X//" >'./README' <<'END_OF_FILE'
The Nelder-Mead simplex method for function minimization is used for
fitting a model function to a set of data.  A best-fit set of parameters
is obtained directly.  A quadratic approximation of the least squares
function surface in the neighborhood of the minimum gives the
information matrix and thus the variance-covariance matrix and the
standard deviations of the parameters (not given directly the by simplex
method).  Alternating cycles of simplex minimization and quadratic
approximation more efficiently converge on the function minimum.
X
The program is stable enough to survive an undergraduate laboratory.  A
version of it has moved with me from Fortran on a main frame, to Fortran
on a mini, to CP/M basic, to CP/M C, and to UNIX.  Perhaps others will
find it as handy to have around as I have.
X
The documentation should be sufficient for relatively painless use of
the program -- including the minimal coding needed for fitting one's own
special functions and data.  Some of the documentation perhaps shows
that it comes from handouts for undergraduates.
X
There is a man page.  To view it:
X
X	make manpage
X
To print it, set P in the makefile and:
X
X	make printmanpage
X
The program reads an ascii file to get control values, starting
parameter estimates, and data.  For pointers on how to construct such a
file, see Input.doc and the sample input files, linefit.dat and ldhfit.dat.
X
Two test functions are coded in ldhfit.c and linefit.c.  To compile and
try them out:
X
X	unshar this file (if appropriate)
X	make
X	make testline
X	make testldh
X
XEach test produces an output file, which is diff'd against each of two
X"standard" results files, which are supplied with the package and were
generated on different systems (under SysV on an AT and 4.3BSD on a Vax
X8650).  Precision and rounding vary with the system, and are apparent
even in these relatively simple calculations, so perhaps one should not
be surprised if the test output agrees with neither of the "standards".
However, the differences should be of course small and consistent with
the precision expected.
X
To see the use of alternating cycles of simplex minimization and
quadratic approximation, compare ldhfit.testx, generated by simplex
minimization only (quad_test set at 0), with ldhfit.test1, generated
with alternating simplex and quadratic approximation.  
X
X
John Rupley
X uucp: ..{uunet | ucbvax | cmcl2 | hao!ncar!noao}!arizona!rupley!local
X internet: rupley!local@megaron.arizona.edu
X (H) 30 Calle Belleza, Tucson AZ 85716 - (602) 325-4533
X (O) Dept. Biochemistry, Univ. Arizona, Tucson AZ 85721 - (602) 621-3929
END_OF_FILE
if test 2590 -ne `wc -c <'./README'`; then
    echo shar: \"'./README'\" unpacked with wrong size!
fi
# end of './README'
fi
if test -f './README.mmfit' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./README.mmfit'\"
else
echo shar: Extracting \"'./README.mmfit'\" \(196 characters\)
sed "s/^X//" >'./README.mmfit' <<'END_OF_FILE'
The directory 
X
X	mmfit
X
contains files useful for fitting enzyme kinetic data to the
Michaelis-Menten (the "mm" of mmfit).
X
XFor a sample calculation, cd to the mmfit directory, and
X
X	make mmtest
X
END_OF_FILE
if test 196 -ne `wc -c <'./README.mmfit'`; then
    echo shar: \"'./README.mmfit'\" unpacked with wrong size!
fi
# end of './README.mmfit'
fi
if test -f './README.probset' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./README.probset'\"
else
echo shar: Extracting \"'./README.probset'\" \(1225 characters\)
sed "s/^X//" >'./README.probset' <<'END_OF_FILE'
The intent of this exercise is to generate familiarity with use
of a computer to solve a routine data reduction problem.
X
XEach student will receive a set of kinetic data, consisting of initial
rates determined for a set of substrate concentrations.  The
measurements are for lactacte dehydrogenase.  The concentrations of the
enzyme and of one substrate, NADH, are fixed.  The concentration of
pyruvate is varied.  Some sets of data are for reaction mixtures
containing also a fixed concentration of product inhibitor, lactate.
The units of rate are arbitrary.  The units of concentration are
millimolar.
X
XEach student should:
X
X	create a directory named after her or him;
X
X	cp a copy of the data.template file into this directory;
X
X	modify with an editor the data.template file, to accord with
X	the set of data points given him or her, and call the new file
X	myfile.dat, perhaps;
X
X	run mmfit, with a command line something like:
X
X		mmfit -sc -dl myfile.dat myfile.out
X
X	obtain a printout of myfile.out;
X
X	hand in:
X
X		an estimate of the maximum velocity with its standard
X		deviation and of the Michaelis constant and its standard 
X		deviation;
X
X		a copy of the printout;
X
X	leave the files, myfile.* or whatever, on the disk.
END_OF_FILE
if test 1225 -ne `wc -c <'./README.probset'`; then
    echo shar: \"'./README.probset'\" unpacked with wrong size!
fi
# end of './README.probset'
fi
if test ! -d './assign' ; then
    echo shar: Creating directory \"'./assign'\"
    mkdir './assign'
fi
if test -f './assign/dataset1' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset1'\"
else
echo shar: Extracting \"'./assign/dataset1'\" \(3508 characters\)
sed "s/^X//" >'./assign/dataset1' <<'END_OF_FILE'
dataset1: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
nvert= 3	nparm= 2
X
ndata= 6	ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X50.0	0	1	.15
X48.5	0	1	.15
X59.5	0	1	.22
X76.0	0	1	.35
X94.0	0	1	.70
X91.5	0	1	.70
X
X
X-----------------------end of data-------------------------------
XFor a very large simplex, try:
X
simplex[nvert][nparm=a,b]= 
X
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X
X----------------------------------------------------------------------
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3508 -ne `wc -c <'./assign/dataset1'`; then
    echo shar: \"'./assign/dataset1'\" unpacked with wrong size!
fi
# end of './assign/dataset1'
fi
if test -f './assign/dataset1.out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset1.out'\"
else
echo shar: Extracting \"'./assign/dataset1.out'\" \(1677 characters\)
sed "s/^X//" >'./assign/dataset1.out' <<'END_OF_FILE'
X
dataset1: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
summary of simplex fitting results:
iteration number 162
X
simplex:
vertex = 0   function value = 7.37962618613172e+00
X   2.2530281008e-01   1.2285675442e+02
vertex = 1   function value = 7.37962618613949e+00
X   2.2530284089e-01   1.2285675996e+02
vertex = 2   function value = 7.37962618613372e+00
X   2.2530281421e-01   1.2285675015e+02
X
centroid:
function value = 7.37962618612187e+00
X   2.2530282173e-01   1.2285675484e+02
mean=7.37962618613498e+00 rms=3.29268280814434e-12 test=4.46185582452768e-13
root mean square weighted error of best fit to data = 1.35827336958855e+00
X
X
dataset1: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
iteration number 162
X
X        yobs   ycalc   del-y  weight       x
X   1  50.000  49.103   0.897   1.000    0.15000
X   2  48.500  49.103  -0.603   1.000    0.15000
X   3  59.500  60.697  -1.197   1.000    0.22000
X   4  76.000  74.743   1.257   1.000    0.35000
X   5  94.000  92.942   1.058   1.000    0.70000
X   6  91.500  92.942  -1.442   1.000    0.70000
X
dataset1: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
summary of results of quadratic fit
iteration number 162
X
mean=7.37962618613498e+00 rms=3.29268280814434e-12 test=4.46185582452768e-13
X
mse    = 1.84490654653047e+00   rms weighted error = 1.35827336958746e+00
X
yzero  = 7.37962618612187e+00
ymin   = 7.37962618611927e+00
y-pmin = 7.37962618611930e+00
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.27738210935e-08 2.25302821730e-01 2.25302809319e-01 1.25572474618e-02
X  1   1 3.41307311658e-06 1.22856754845e+02 1.22856751817e+02 2.61090076525e+00
END_OF_FILE
echo shar: 3 control characters may be missing from \"'./assign/dataset1.out'\"
if test 1677 -ne `wc -c <'./assign/dataset1.out'`; then
    echo shar: \"'./assign/dataset1.out'\" unpacked with wrong size!
fi
# end of './assign/dataset1.out'
fi
if test -f './assign/dataset2' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset2'\"
else
echo shar: Extracting \"'./assign/dataset2'\" \(3508 characters\)
sed "s/^X//" >'./assign/dataset2' <<'END_OF_FILE'
dataset2: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
nvert= 3	nparm= 2
X
ndata= 6	ndatval= 4
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X40.6	0	1	.15
X41.4	0	1	.15
X49.8	0	1	.22
X63.8	0	1	.35
X80.3	0	1	.70
X77.4	0	1	.70
X
X
X-----------------------end of data-------------------------------
XFor a very large simplex, try:
X
simplex[nvert][nparm=a,b]= 
X
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X
X----------------------------------------------------------------------
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3508 -ne `wc -c <'./assign/dataset2'`; then
    echo shar: \"'./assign/dataset2'\" unpacked with wrong size!
fi
# end of './assign/dataset2'
fi
if test -f './assign/dataset2.out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset2.out'\"
else
echo shar: Extracting \"'./assign/dataset2.out'\" \(1677 characters\)
sed "s/^X//" >'./assign/dataset2.out' <<'END_OF_FILE'
X
dataset2: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
summary of simplex fitting results:
iteration number 146
X
simplex:
vertex = 0   function value = 6.27355973414009e+00
X   2.3917811852e-01   1.0595032197e+02
vertex = 1   function value = 6.27355973415214e+00
X   2.3917816758e-01   1.0595033031e+02
vertex = 2   function value = 6.27355973414277e+00
X   2.3917812380e-01   1.0595032415e+02
X
centroid:
function value = 6.27355973414073e+00
X   2.3917813663e-01   1.0595032547e+02
mean=6.27355973414500e+00 rms=5.16610110977143e-12 test=8.23472052342784e-13
root mean square weighted error of best fit to data = 1.25235375734455e+00
X
X
dataset2: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
iteration number 146
X
X        yobs   ycalc   del-y  weight       x
X   1  40.600  40.836  -0.236   1.000    0.15000
X   2  41.400  40.836   0.564   1.000    0.15000
X   3  49.800  50.763  -0.963   1.000    0.22000
X   4  63.800  62.940   0.860   1.000    0.35000
X   5  80.300  78.968   1.332   1.000    0.70000
X   6  77.400  78.968  -1.568   1.000    0.70000
X
dataset2: ldh, fixed nadh=.035 mM, pyruvate varied mM, no lactate
X
summary of results of quadratic fit
iteration number 146
X
mean=6.27355973414500e+00 rms=5.16610110977143e-12 test=8.23472052342784e-13
X
mse    = 1.56838993353502e+00   rms weighted error = 1.25235375734455e+00
X
yzero  = 6.27355973414009e+00
ymin   = 6.27355973413954e+00
y-pmin = 6.27355973413955e+00
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.81120882366e-08 2.39178118522e-01 2.39178126975e-01 1.44378400275e-02
X  1   1 3.50775336718e-06 1.05950321966e+02 1.05950323404e+02 2.50184914944e+00
END_OF_FILE
echo shar: 3 control characters may be missing from \"'./assign/dataset2.out'\"
if test 1677 -ne `wc -c <'./assign/dataset2.out'`; then
    echo shar: \"'./assign/dataset2.out'\" unpacked with wrong size!
fi
# end of './assign/dataset2.out'
fi
if test -f './assign/dataset3.out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset3.out'\"
else
echo shar: Extracting \"'./assign/dataset3.out'\" \(1707 characters\)
sed "s/^X//" >'./assign/dataset3.out' <<'END_OF_FILE'
X
dataset3: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
summary of simplex fitting results:
iteration number 166
X
simplex:
vertex = 0   function value = 9.38174590054538e+00
X   3.7502349319e-01   8.5266765267e+01
vertex = 1   function value = 9.38174590054909e+00
X   3.7502346970e-01   8.5266758195e+01
vertex = 2   function value = 9.38174590054223e+00
X   3.7502358479e-01   8.5266773452e+01
X
centroid:
function value = 9.38174590053686e+00
X   3.7502351589e-01   8.5266765638e+01
mean=9.38174590054557e+00 rms=2.80092778537291e-12 test=2.98550804409447e-13
root mean square weighted error of best fit to data = 1.53148179066430e+00
X
X
dataset3: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
iteration number 166
X
X        yobs   ycalc   del-y  weight       x
X   1  24.800  24.361   0.439   1.000    0.15000
X   2  23.700  24.361  -0.661   1.000    0.15000
X   3  32.500  31.526   0.974   1.000    0.22000
X   4  40.200  41.162  -0.962   1.000    0.35000
X   5  57.500  55.521   1.979   1.000    0.70000
X   6  53.800  55.521  -1.721   1.000    0.70000
X
dataset3: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
summary of results of quadratic fit
iteration number 166
X
mean=9.38174590054557e+00 rms=2.80092778537291e-12 test=2.98550804409447e-13
X
mse    = 2.34543647513421e+00   rms weighted error = 1.53148179066361e+00
X
yzero  = 9.38174590053686e+00
ymin   = 9.38174590053645e+00
y-pmin = 9.38174590053645e+00
X
free parm    q                centroid         pmin             std_dev
X  0   0 4.59301218725e-08 3.75023515894e-01 3.75023529488e-01 4.22041235734e-02
X  1   1 5.20932336675e-06 8.52667656376e+01 8.52667666843e+01 4.49466968882e+00
END_OF_FILE
echo shar: 3 control characters may be missing from \"'./assign/dataset3.out'\"
if test 1707 -ne `wc -c <'./assign/dataset3.out'`; then
    echo shar: \"'./assign/dataset3.out'\" unpacked with wrong size!
fi
# end of './assign/dataset3.out'
fi
if test -f './assign/dataset4.out' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./assign/dataset4.out'\"
else
echo shar: Extracting \"'./assign/dataset4.out'\" \(1707 characters\)
sed "s/^X//" >'./assign/dataset4.out' <<'END_OF_FILE'
X
dataset4: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
summary of simplex fitting results:
iteration number 184
X
simplex:
vertex = 0   function value = 1.73375252909136e+01
X   3.5930122869e-01   6.5006046538e+01
vertex = 1   function value = 1.73375252909227e+01
X   3.5930119702e-01   6.5006049371e+01
vertex = 2   function value = 1.73375252909070e+01
X   3.5930120409e-01   6.5006046635e+01
X
centroid:
function value = 1.73375252909073e+01
X   3.5930120993e-01   6.5006047515e+01
mean=1.73375252909144e+01 rms=6.42531096989187e-12 test=3.70601389879961e-13
root mean square weighted error of best fit to data = 2.08191770315898e+00
X
X
dataset4: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
iteration number 184
X
X        yobs   ycalc   del-y  weight       x
X   1  21.000  19.146   1.854   1.000    0.15000
X   2  19.600  19.146   0.454   1.000    0.15000
X   3  22.800  24.687  -1.887   1.000    0.22000
X   4  31.500  32.077  -0.577   1.000    0.35000
X   5  41.000  42.957  -1.957   1.000    0.70000
X   6  45.400  42.957   2.443   1.000    0.70000
X
dataset4: ldh, fixed nadh=.035 mM, pyruvate varied mM, fixed lactate=150 mM
X
summary of results of quadratic fit
iteration number 184
X
mean=1.73375252909144e+01 rms=6.42531096989187e-12 test=3.70601389879961e-13
X
mse    = 4.33438132272676e+00   rms weighted error = 2.08191770315898e+00
X
yzero  = 1.73375252909070e+01
ymin   = 1.73375252909070e+01
y-pmin = 1.73375252909070e+01
X
free parm    q                centroid         pmin             std_dev
X  0   0 1.05584493001e-08 3.59301204094e-01 3.59301204328e-01 7.98327001465e-02
X  1   1 9.44371322475e-07 6.50060466352e+01 6.50060466546e+01 6.60616031700e+00
END_OF_FILE
echo shar: 3 control characters may be missing from \"'./assign/dataset4.out'\"
if test 1707 -ne `wc -c <'./assign/dataset4.out'`; then
    echo shar: \"'./assign/dataset4.out'\" unpacked with wrong size!
fi
# end of './assign/dataset4.out'
fi
if test ! -d './mmfit' ; then
    echo shar: Creating directory \"'./mmfit'\"
    mkdir './mmfit'
fi
if test -f './mmfit/Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/Makefile'\"
else
echo shar: Extracting \"'./mmfit/Makefile'\" \(1173 characters\)
sed "s/^X//" >'./mmfit/Makefile' <<'END_OF_FILE'
P=		lp
X
LIBDIR= ../Lib
X
LIBOBJECTS=\
X		$(LIBDIR)/simpinput.o \
X		$(LIBDIR)/simpmain.o \
X		$(LIBDIR)/simpfit.o \
X		$(LIBDIR)/simpdev.o \
X		$(LIBDIR)/simplib0.o
X
LINT=		lint -uvx 
X
LIBES=		-lm
X
CFLAGS=		-O -I${LIBDIR}
X
mmfit:	mmfit.o $(LIBOBJECTS)
X		cc $(CFLAGS) mmfit.o $(LIBOBJECTS) $(LIBES) -o mmfit
X		size mmfit
X
mmtest: mmfit mmfit.dat
X		mmfit -da mmfit.dat mmfit.out
X
mmfit.o: $(LIBDIR)/simpdefs.h
X
recipfit:	recipfit.o $(LIBOBJECTS)
X		cc $(CFLAGS) recipfit.o $(LIBOBJECTS) $(LIBES) -o recipfit
X		size recipfit
X
recipfit.o: $(LIBDIR)/simpdefs.h
X
reciptest: recipfit recipfit.dat
X		recipfit -da recipfit.dat recipfit.out
X
recip_nowt:	recip_nowt.o $(LIBOBJECTS)
X		cc $(CFLAGS) recip_nowt.o $(LIBOBJECTS) $(LIBES) -o recip_nowt
X		size recip_nowt
X
recip_nowt.o: $(LIBDIR)/simpdefs.h
X
nowttest: recip_nowt recipfit.dat
X		recip_nowt -da recipfit.dat recip_nowt.out
X
X$(LIBOBJECTS): $(LIBDIR)/simpdefs.h
X	(cd $(LIBDIR); $(CC) $(CFLAGS) -c $< )
X
shar:
X	shar Makefile mm.sh mmall.out mmfit.c mmfit.dat mmfit.out nowt.sh nowtall.out recip.sh recip_nowt.c recip_nowt.out recipall.out recipfit.c recipfit.dat recipfit.out >mmfit.shar
X
clean:
X	rm *.out *.o mmfit recipfit recip_nowt
END_OF_FILE
if test 1173 -ne `wc -c <'./mmfit/Makefile'`; then
    echo shar: \"'./mmfit/Makefile'\" unpacked with wrong size!
fi
# end of './mmfit/Makefile'
fi
if test -f './mmfit/data.template' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/data.template'\"
else
echo shar: Extracting \"'./mmfit/data.template'\" \(3408 characters\)
sed "s/^X//" >'./mmfit/data.template' <<'END_OF_FILE'
X[DEMONSTRATION DATA ENTRY FILE  -  REPLACE THIS LINE BY ONE-LINE TITLE]
X 
X
nvert= (ENTER-VALUE-HERE)	nparm= (ENTER-VALUE-HERE)
X
ndata= (ENTER-VALUE-HERE)	ndatval= (ENTER-VALUE-HERE)
X
iter= 0			maxquad_skip= 4		exit_test= 1.E-8
X
prt_cycle= 30		quad_test= 30
X 
X
starting-simplex[nvert][nparm=list_starting_parameter_values]= 
X
X[REPLACE THIS LINE BY NVERT SETS OF NPARM VALUES]
X 
X
data[ndata][ndatval=y,yc,w,list_independent_variable_values]=
X
X[REPLACE THIS LINE BY NDATA SETS OF NDATVAL VALUES]
X
X
X-----------------------end of data-------------------------------
X
Comments:
X
the first line, a ONE-LINE title, can have no control characters or
tabs;
X
the ONE-WORD (there can be NO white space within them) mnemonic
identifiers ("data[ndata][ndatval=y,yc,w,...]=", "nvert=", etc.) must
ALL be present;
X
the identifier must be separated by white space from the value(s)
following for it;
X
the order of presentation of the identifier-value sets is fixed, but the
number of spaces or tabs or newlines, etc., between tokens is not
important (i.e., there are no format fields);
X
the number of values read after "simplex.." is <nvert> x <nparm>; there
are <nvert> vertices of the simplex, one more than the number of "free"
parameters; there are <nparm> values given for each vertex, each value
being an estimate of a parameter value; not all of the <nparm>
parameters need be "free"; a "fixed" parameter has the same value for
all vertices; for a parameter to be "free", at least one vertex must
differ from other vertices in the value for that parameter; the high and
low values for a "free" parameter, comparing all vertices, should
determine a range that includes the best-fit value of that parameter;
the fitting procedure may be able to find a best-fit value outside the 
initial range.
X
the number of values read in the set of values after "data.." is <ndata>
x <ndatval>; <ndatval> is greater than or equal to 4, because the
aggregate <data> must store for each data point values for y(observed),
y(calculated), the statistical weight, and one or more independent
variables;
X
descriptive comments (like these) can be placed at the end of the data
file.
X
X
NOTE:
X
set the starting simplex large, to include any reasonable best-fit
values of the principal parameters;
X
set exit_test tight, to minimize problems with the quadratic fit;
X
set prt_cycle and quad_test at 30, so that every 30 iterations the
intermediate results are stored on disk and selectively a quadratic
fitting is carried out, to speed convergence;
X
set maxquad_skip nonzero; then if a quadratic fit fails, the next one or
more quadratic fit attempts are passed over; the number passed over is
incremented at each successive failure, up to maxquad_skip; a successful
quadratic fit resets the skip counter;
X
set iter, the starting iteration number, at 0;
X
minimization continues until the value of <test> is less than
X<exit_test>:
X
X     <exit_test> = input value
X     <test>      = <rms_func> / <mean_func>
X     <rms_func>  = (root mean square of the deviations
X                              of the least squares values
X                              at the simplex vertices)
X     <mean_func> = (mean of the least squares values)
X
on exit from the minimization, a pass through simpdev() gives the
final estimates of the standard deviations of the parameters;
X
read_data() has code for reading in parameter bounds; please consult
the source code.
X
END_OF_FILE
if test 3408 -ne `wc -c <'./mmfit/data.template'`; then
    echo shar: \"'./mmfit/data.template'\" unpacked with wrong size!
fi
# end of './mmfit/data.template'
fi
if test -f './mmfit/mmfit.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/mmfit.c'\"
else
echo shar: Extracting \"'./mmfit/mmfit.c'\" \(3442 characters\)
sed "s/^X//" >'./mmfit/mmfit.c' <<'END_OF_FILE'
X/* MMFIT.C */
X/*-
VERSION OF XXXXFIT, for:
X  
nonlinear least squares fit by simplex minimizaton (Nelder-Mead algorithm).
X  
test:
X	Michaelis-Menten rate law
X */
X/*-
contents of the XXXXFIT module  =  
declarations and routines for simplex fitting special to function to be fit
X(no other functions/files need to be rewritten or adapted for a new model):
X  
X	mnemonic defines for members of data and parameter structures
X  
X	function for calculation of dependent variable and
X		weighted sum of residuals squared		= func()
X  
X	print of <data> records					= fdatprint()
X  
X	additional display called by fdatprint(), 
X		specially written for this model 		= fpointprint()
X  
X	customizable display called by <simpfit()>, 
X		following the output tracking each cycle
X		of minimization					= fspecial()
X  
J.A. Rupley, Tucson, Arizona
rupley!local@megaron.arizona.edu
X*/
X
X#define XXXXFIT
X
X#include "simpdefs.h"		/* externals are read from <simpdefs> */
X
X/* DEFINES SPECIAL TO FITTING FUNCTION */
X
X#define Y	0		/* defines for elements of struct dat */
X#define YC	1		/* (mnemonic) */
X#define W	2
X#define X	3
X
X#define A	0		/* defines for elements of struct pstruct */
X#define B	1		/* (mnemonic) */
X
X/*-
XFUNC
X	CALCULATION OF LEAST SQUARES FUNCTION
X	CODED ACCORDING TO MODEL BEING FIT
X	IT SHOULD BE EFFICIENT
X	DURING THE FIT, TIME IS MOSTLY SPENT HERE
X*/
X
int
func(pnam)
X	struct pstruct *pnam;
X{
X	register int    n;
X
X	extern struct dat data[];
X	extern int      nparm;
X	extern int      ndata;
X
X	/*
X	 * here set/test bounds on parms...not applicable to linefit 
X	 */
X
X	pnam->val = 0;
X	for (n = 0; n < ndata; n++) {
X		/* evaluation of dependent variable */
X		data[n].datval[YC] = pnam->parm[B] * data[n].datval[X] /
X				(pnam->parm[A] + data[n].datval[X]) ;
X		/* evaluation of weighted sum of residuals squared */
X		pnam->val = pnam->val
X			+ (data[n].datval[Y] - data[n].datval[YC])
X			* (data[n].datval[Y] - data[n].datval[YC])
X			* data[n].datval[W]
X			* data[n].datval[W];
X	}
X	return (OK);
X}				/* END OF FUNC        			 */
X
X/*-
XFDATPRINT
X	PRINT DATA AND COMPARE WITH CALCULATED VALUES
X	CODED ACCORDING TO MODEL AND DATA
X*/
X
void
fdatprint(fptr)
X	FILE           *fptr;
X{
X	register int    j;
X
X	extern void     fpointprint();
X
X	extern int      iter, ndata, maxiter;
X	extern struct dat data[];
X	extern char     title[];
X
X	fprintf(fptr, "\1\f\n%-s\n\niteration number %d\n\n", title, iter);
X	fprintf(fptr,
X		"        yobs   ycalc   del-y  weight       x\n");
X	for (j = 0; j < ndata; j++)
X		fprintf(fptr,
X			"%4d %7.3f %7.3f %7.3f %7.3f %10.5f\n",
X			(j + 1), data[j].datval[Y], data[j].datval[YC],
X			(data[j].datval[Y] - data[j].datval[YC]),
X			data[j].datval[W], data[j].datval[X]);
X
X	if (maxiter != 0)
X		fpointprint(fptr);
X}				/* END OF FDATPRINT			 */
X
X/*-
XFPOINTPRINT
X	CODE FOR SPECIAL OUTPUT, IF ANY
X*/
X
void
fpointprint(fptr)
X	FILE           *fptr;
X{
X}				/* END OF FPOINTPRINT			 */
X
X
X/*-
XFSPECIAL
X	DISPLAY ADDITIONAL INFORMATION DURING
X	TRACKING OF MINIMIZATION, IN SIMPFIT()
X*/
X
void
fspecial(fptr)
X	FILE           *fptr;
X{
X	register        j;
X
X	extern int      maxiter;
X	extern double   ypmin, yzero, quad_test;
X
X	if (ypmin > 0.99E38) {
X		fprintf(fptr, "y-pmin error");
X		for (j = 0; j < nvert; j++)
X			if (pmin.parm[j] < 0)
X				fprintf(fptr, " (parm(%d) < 0)", j);
X	} else if (ypmin > yzero)
X		fprintf(fptr, "y-pmin > yzero");
X
X	fprintf(fptr, "    next_prt= %d  next_quad= %7.2e\n",
X		maxiter, quad_test);
X
X	return;
X}				/* END OF FSPECIAL			 */
END_OF_FILE
if test 3442 -ne `wc -c <'./mmfit/mmfit.c'`; then
    echo shar: \"'./mmfit/mmfit.c'\" unpacked with wrong size!
fi
# end of './mmfit/mmfit.c'
fi
if test -f './mmfit/recipfit.dat' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'./mmfit/recipfit.dat'\"
else
echo shar: Extracting \"'./mmfit/recipfit.dat'\" \(561 characters\)
sed "s/^X//" >'./mmfit/recipfit.dat' <<'END_OF_FILE'
nonlinear least squares on Lineweaver-Burke (with data given as v/s pairs)
X 
nvert= 3		nparm= 2
X
ndata= 9		ndatval= 4
X
iter= 0			maxquad_skip= 1		exit_test= 1.E-12
X
prt_cycle= 30		quad_test= 30
X 
simplex[nvert][nparm=a,b]= 
X1.e-4	1.e+1
X1.e-5	1.e+1
X1.e-4	1.e+0
X
X 
data[ndata][y,yc,w,x]= 
X.105	0	1	.00015
X.100	0	1	.00009
X.095	0	1	.00006
X.083	0	1	.00006
X.080	0	1	.00004
X.074	0	1	.00004
X.061	0	1	.00003
X.054	0	1	.00002
X.051	0	1	.00002
X
X
simplex[nvert][nparm=a,b]= 
X1.e-5	1.e-1
X1.e-6	1.e-1
X1.e-5	1.e-0
X
X 
simplex[nvert][nparm=a,b]= 
X1.e-6	1.e-6
X1e6	1.e-6
X1.e-6	1e6
X
END_OF_FILE
if test 561 -ne `wc -c <'./mmfit/recipfit.dat'`; then
    echo shar: \"'./mmfit/recipfit.dat'\" unpacked with wrong size!
fi
# end of './mmfit/recipfit.dat'
fi
if test -f 'MANIFEST' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'MANIFEST'\"
else
echo shar: Extracting \"'MANIFEST'\" \(1633 characters\)
sed "s/^X//" >'MANIFEST' <<'END_OF_FILE'
X   File Name		Archive #	Description
X-----------------------------------------------------------
X ./Doc                      1	
X ./Doc/Data_redn.doc        4	
X ./Doc/Input.doc            1	
X ./Doc/Output.doc           3	
X ./Doc/Simplex.doc          4	
X ./Doc/simplex.1            2	
X ./Ldh                      1	
X ./Ldh/ldhfit.c             3	
X ./Ldh/ldhfit.dat           1	
X ./Ldh/ldhfit.test1         3	
X ./Ldh/ldhfit.test2         2	
X ./Ldh/ldhfit.testx         3	
X ./Lib                      1	
X ./Lib/Makefile             1	
X ./Lib/simpdefs.h           1	
X ./Lib/simpdev.c            3	
X ./Lib/simpfit.c            2	
X ./Lib/simpinput.c          3	
X ./Lib/simplib0.c           2	
X ./Lib/simpmain.c           3	
X ./Line                     1	
X ./Line/linefit.c           1	
X ./Line/linefit.dat         1	
X ./Line/linefit.test        2	
X ./Line/linefit.test1       1	
X ./Line/linefit.test2       1	
X ./Makefile                 1	
X ./README                   1	
X ./README.mmfit             1	
X ./README.probset           1	
X ./assign                   1	
X ./assign/dataset1          1	
X ./assign/dataset1.out      1	
X ./assign/dataset2          1	
X ./assign/dataset2.out      1	
X ./assign/dataset3          2	
X ./assign/dataset3.out      1	
X ./assign/dataset4          2	
X ./assign/dataset4.out      1	
X ./mmfit                    1	
X ./mmfit/Makefile           1	
X ./mmfit/data.sample        2	
X ./mmfit/data.template      1	
X ./mmfit/mmfit.c            1	
X ./mmfit/mmfit.dat          2	
X ./mmfit/recip_nowt.c       2	
X ./mmfit/recipfit.c         2	
X ./mmfit/recipfit.dat       1	
X MANIFEST                   1	This shipping list
END_OF_FILE
if test 1633 -ne `wc -c <'MANIFEST'`; then
    echo shar: \"'MANIFEST'\" unpacked with wrong size!
fi
# end of 'MANIFEST'
fi
echo shar: End of archive 1 \(of 4\).
cp /dev/null ark1isdone
MISSING=""
for I in 1 2 3 4 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 4 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0


