Using Extended Memory to save Statistics Registers
Statistics use 6 regular registers to keep track of data for calculating Mean and Standard Deviations.
Keeping a long-term record of a set of variables means not being able to use the Statistics functions for anything else unless steps are taken to save and restore the registers.
It is possible to save the 6 registers in a data file in Extended Memory and then use the statistics for other things, and restore the saved Statistics back to Main Memory when required.
By Default the Statistics registers start at R11 but this can be changed with the command ∑REG
This is the default list of Statistics Registers and contents
| R11 | ∑x | Summation of x-values |
| R12 | ∑x2 | Summation of squares of x-values. |
| R13 | ∑y | Summation of y-values. |
| R14 | ∑y2 | Summation of squares of y-values. |
| R15 | ∑xy | Summation of products of x- and y-values. |
| R16 | n | Number of data points accumulated. |
Advantage Pac : CFIT application seems to reset ∑REG to 12
The statistics registers use 6 Main Memory registers, usually R11 → R16
We need to create a Data File in Extended Memory to hold these.
ALPHA e.g. REGS6 in x registerCRFLD to create the Data File REGS in Extended MemoryOnce it's created it can be used to hold the contents of the 6 Statistics Registers
REGS in ALPHA0 in X so that we put the pointer at the first register record in the data file.SEEKPTAREGSREGS is still in ALPHAX to indicate which range of Registers to save, this is bbb.eee where b is the beginning register and e is the end11.016 in XSAVERXREGS in ALPHA0 in X SEEKPTAREGS back to R11 → R16REGS is still in ALPHAX to indicate where the recovered registers will be put in Main Memory 11.016 in XGETRXIt is possible to change the base register of the 6 Statistics Registers, away from the default of R11.
We need to take this into account.
This uses the query ∑REG? to find the base register, then create bbb.eee using simple arithmetic.
When used in SAVER (saveRegs) we ensure we copy the current Statistics Registers data.
When used in GETR (getRegs) we ensure we restore our data to the Registers currently set to be the active Statistics Registers (they may have changed since first saving them)
LBL ¬SAVER ¬REGS 0 SEEKPTA ∑REG? 1.001 * .005 + SAVERX ¬REGS SAVED AVIEW PSE CLD RTN LBL ¬GETR ¬REGS 0 SEEKPTA ∑REG? 1.001 * .005 + GETRX ¬REGS OK AVIEW PSE CLD RTN
It's possible to have more than one Extended Memory file with Stats registers.
This could keep track of different sets of statistics and allow restore, update, save for many sets of statistical data.
I've set up two data files : REGS and CHESS in extended memory and made two version of the simple program above, the only change is to alter the lines which put the name of the file in ALPHA
Then I thought of adding a 7th Register holding the DATE of the latest SAVE for the CHESS statistics, so I can keep track of whether I'm up to date in entering the scores.
Delete the original CHESS Data File & make a new one with 7 registers
ALPHA → CHESSPURFLX = 7ALPHA still → CHESSCRFLD to create the new 7-register data file
The date is automatically stored in the register just after the Stats - in general in R18 when ΣREG is 12 - and automatically adapts the register used depending on ΣREG?
Here is SAVEC and GETC for saveChess and getChess
LBL ¬SAVEC ¬CHESS 0 SEEKPTA ∑REG? STO 01 6 + STO 00 DATE STO IND 00 RCL 01 1.001 * .006 + SAVERX ¬CHESS SAVED AVIEW PSE CLD RTN END
LBL ¬GETC ¬CHESS 0 SEEKPTA ∑REG? STO 01 6 + STO 00 RCL 01 1.001 * .006 + GETRX CLA RCL IND 00 ¬LAST ADATE AVIEW PSE CLD RTN END
I might make a better version which prompts for a Data File name rather than having one separate program for each scenario