horlache@sun1.ruf.uni-freiburg.de (Ullrich Horlacher) (03/07/90)
Hi there in HP28-country, Exams are over and I have now the time to post my (for my usage) most usefullest program(-system) for the HP28-S : STATS is a collection of some prgs on statistics, which computes functions and derivations of x/y-data and draws them. It is *very* simple to use. I use STATS in my study in several practica, in which one have to measure a lot of data and calculate functions of this data with linear regression, general regression or splines. (U/I-diagrams, titration curves etc) I collected the algorythms of the various programs of STATS from different sources (Script "Splines-Anwendungen, Technische Universitaet Muenchen"; Book "Walcher: Praktikum der Physik"; Script "Beitraege zur Rechenarithmetik", Regionales Rechenzentrum Nordrhein-Westfalen; discussion with Dr. Waldbauer Universitaet Ulm). The explanations of all those algorythms would be much (!) longer than the code itself, so I'll make only some remarks on STATS. A while ago I posted a subset of STATS. You can use this older version further more. If anyone has some suggestions on improvement either on the code or even the algorythms, send them to me. I'll be very interested. To use STATS effectly I suggest, put it in an own directory and create a costum menu like: stat.dir CRDIR << stat.dir { LREG GREG SINIT SPL SDRW &DAT EQ RS RF &DEV } MENU >> STATS STO ------------------------------prg-sources--------------------------------------- Linear Regression: -------------------- LREG << ->xy LR 'X' * SWAP + ->RS >> General Regression: ----------------------- GREG << DUP IF TYPE 5 <> THEN ->LIST END 'RF' STO ->xy 1 N& FOR i x i GET 'X' STO 1 RF SIZE FOR j RF j GET ->NUM NEXT NEXT N& RF SIZE 2 ->LIST ->ARRAY DUP TRN DUP ROT * INV SWAP * y * 'k' STO 0 1 RF SIZE FOR i k i GET RF i GET * + NEXT ->RS >> Spline Initialisation : ------------------------- SINIT << 0 0 N& 1 - -> r s n << ->xy x 0 * DUP DUP 'C' STO 'B' STO 'A' STO 1 n FOR i y i 1 + GET y i GET - x i 1 + GET x i GET - DUP 'C(i)' STO / 'r' STO 'B' i r s - PUT r 's' STO NEXT 0 'r' STO 'B' 1 0 PUT 2 n FOR i 'B' i B i GET B i 1 - GET r * + PUT 'A' i x i 1 - GET x i 1 + GET - 2 * r s * - PUT C i GET 's' STO s A i GET / 'r' STO NEXT n 2 FOR i 'B' i C i GET B i 1 + GET * B i GET - A i GET / PUT -1 STEP 'B' 3 STO* 1 n FOR i C i GET 's' STO B i 1 + GET B i GET - 3 / 'r' STO 'C' i r s / PUT 'A' i y i 1 + GET y i GET - s / B i GET r + s * - PUT NEXT >> "X SPL" IEQ >> Spline Function : ------------------- SPL << -> z << 1 DO 1 + UNTIL x OVER GET z >= END 1 - z x 3 PICK GET - C 3 PICK GET OVER * B 4 PICK GET + OVER * A 4 PICK GET + * y ROT GET + >> >> Central Plotting Routine : ---------------------------- SDRW << ->xy CLLCD IFERR 'PPAR' RCL THEN SCL& END DROP DRW& IFERR DRAW THEN END '&PAR' PURGE DGTIZ >> !draws the function and stops on every keystroke (except ON), to continue with !digitizing Subroutines : --------------- ->xy << &DAT DUP TRN STO& &- 'y' STO &- 'x' STO STO& >> !creates x- and y-vectors for quicker computing ->RS << STEQ 0 'RS' STO x 0 * '&DEV' STO 1 N& FOR i x i GET 'X' STO 'y(i)-EQ' ->NUM DUP '&DEV(i)' STO SQ 'RS' STO+ NEXT RS N& 1 - / sqrt_sign 'RS' STO { X k } PURGE >> !computes the standard-deviation IEQ << ->STR "<<KEY<<integral_sign>>IFT " SWAP + STR-> STEQ >> !creates the executable spline-function called by SDRW ----------------------------prg-sources-end------------------------------------ Instructions: ------------- The data must be in the object &DAT (standard-object for statistics). e.g: [[ 1 1 ] [ 2 2.2 ] [ 3 2.9 ] [ -.8 -1.1 ]] &DAT STO ------ For linear regression type LREG ==> you get the objects: EQ with the computed equation RS with the standard deviation &DEV with a list of single-deviations ------ For general regression there must be a list of basis-functions in the stack: eg: { 1 'X' 'X*X' 'EXP(X)} or this list in the LIST-> form: 1 'X' 'X*X' 'EXP(X)' 4 then type GREG ==> you get the objects: EQ with the computed regression-equation RS with the standard deviation &DEV with a list of single-deviations RF with the list of the basis-functions { 1 'X' } GREG ! and LREG ! are equal! { 1 'X' 'X*X' } GREG ! is a quadratic regression Please remember that polynomical functions: a*x^0 + b*x^1 + c*x^2 + d*x^3 + ... are only a subset of the used generally term: a*f1(x) + b*f2(x) + c*f3(x) + ... ------ For splines (unknown function type; draws a function through all data-points) just type SINIT for initialisation. Then you can compute single values with number SPL (eg: 3.4 SPL) or 'SPL(number)' or draw the whole function with SDRW Derivations cannot be computed in this modus. ------ You can easily draw the functions with the prg SDRW. ------------------------------------------------------------------------------ Legend: & := the Sigma character ------- <> := the not equal character sqrt_sign := the squareroot character integral_sign := the integral character #-------------------------------------------------------------------# # this mail came from Framstag! (sometimes known as Ulli Horlacher) # # framstag@dtupev5a.bitnet ullrich.horlacher@ruf.uni-freiburg.dbp.de # # horlache@sun1.ruf.uni-freiburg.de # "Waiting for the prompt" -Marillion # #---------------------------------------------------------------------------#