Classic Computer Magazine Archive ANTIC VOL. 6, NO. 8 / DECEMBER 1987

Featured Application

Science Statistician


Data in, analysis out

Science Statistician is just what you need for all those laboratory experiments where you have to calculate averages and standard deviations for your results. This BASIC program works on 8-bit Atari computers with at least 32K memory, disk or cassette.

As you start taking science classes in high school--and continuing throughout your university career--you quickly find that much of your laboratory responsibilities consist of calculating averages, standard deviations and other statistical information about your experimental data.

This means a lot of number crunching, whether you are studying chemistry, biology, physics, engineering or any other science--not to mention all that graphing of unusual-looking functions for your required math classes. And what's better for brute-strength number crunching than your trusty Atari computer?

I decided to write a program that determines averages and standard deviations from given data sets after discovering that my college chemistry class mainly tested number-crunching skills.

I added the ability to fit a curve to the data--given that you take the logarithms of X and/or Y (Analysis Menu, choice 4). For a computer science class I had previously written a program that draws graphs of functions, so I decided to add this feature to my program.

Science Statistician is menu-driven and easy to use. It does a variety of tedious and painstaking jobs. The program can graph any legal function over a given interval, or perform a numerical integration for given limits. It lets you type in data or data points which can then be graphed or analyzed, with the analysis consisting of standard and average deviations as well as curve-fitting.

Graphs and data can then be printed for later analysis. Note that the trigonometric functions use radians, not degrees.

After using Pascal and C++, I realized how much I missed having the functions and procedures each of these languages offers. So instead I used subroutines allowing my pseudo-BASIC functions and procedures to be called by any part of the program. Though they're not as simple or quick as those in a structured language, these subroutines can divide a big program into smaller modules which are much simpler to code and debug.

It also makes using subroutines from other sources much easier, because computer science problems often rely on using or adapting standard algorithms to solve a problem. I also use two machine language routines. One prints text on a Graphics 8 screen and the other dumps a graphics screen to the printer.


Do you need help with all those statistical assignments this term? Here it is -- Science Statistician. Type in Listing 1, SCIHELP.BAS, check it with TYPO II and SAVE a copy before you RUN it.

If you have trouble typing in the special characters in lines 14000-15140, don't type them in. Listing 2 will create them for you. Type Listing 2, checking it with TYPO II and SAVE a copy. When RUN, Listing 2 creates these hard-to-type lines, and stores them in a file called LINES.LST.

To merge the two programs, LOAD "D:SCIHELP.BAS" then ENTER "D:LINES.LST". Cassette Owners: CLOAD Listing I, then insert the cassette used with Listing 2 and ENTER "C".

Finally, remember to SAVE the completed program before you RUN it. Science Statistician is a self-modifying program which must be typed-in very carefully. Be sure to type in every line of the program and do not renumber it.


The program uses your Atari's "forced read" mode to change the function to be plotted. This function is defined in line 30. The forced read mode, found in line 4000-4080, lets your Atari read information from the screen editor. Here's how it works:

4030--Halfway down the screen, your Atari prints:

30 FATX =

Note that the cursor remains at the end of this line and does not return to the left margin.

404O--Here, we INPUT the function to be plotted, filling in the right half of line 30. (Be sure to use proper BASIC syntax.)

4045--The computer skips a few lines and prints the word CONT.

4050--The computer places the cursor several lines above line 30.

4060--The statement POKE 842,13 places your Atari, into forced read mode. (This POKE is followed by a STOP command, which we'll discuss shortly). If you imagine an invisible hand pressing [RETURN] over and over again, you'll get a good idea of what this mode does.

Let's use COS(X)* SIN(X) as a sample function. Here's what the screen will look like:

Starting near the top of the screen, our "invisible hand" presses one carriage return after another. If the cursor happens to be on the same line as a BASIC statement when the invisible hand presses [RETURN], then that statement becomes part of the program. If the cursor is on the same line as a BASIC command, then that command is executed. The first line that the cursor passes across is our new line 30. This automatically replaces our old line 30.

The STOP command in line 4060 STOPs your program, but it does not stop the forced read mode.

Next, the cursor passes across the word CONT, a BASIC command which tells your program to CONTinue running, beginning at the next line.

4070--The statemmt POKE 842,12 deactivates the forced read mode. Your Atari functions runs normally again.

Robert Witzofsky is a junior at Washington University of St. Louis, majoring in electrical engineering and computer science. This is his first appearance in Antic.

Listing:SCIHELP.BAS Download