RetroChallenge Day 7 – Post 5 Documenting formulas, Sample STATS Code

Moving on from the Dorsett tapes on Statistics to coding the STATS program in Pascal on the emulated Atari 400/800 I am starting with documenting stats formulas in a text file with the ED editor that comes with Kayan Pascal.  Now I will need to take some liberties with typing them in as there are limited characters to do so.  Then perhaps this file can be tied into the program as some help.

This post will include the formulas for Mean, Standard Deviation, Variation, Skewness and Kurtosis, (peaked-ness of a distribution).  Along with some quick and dirty Pascal code to implement as a sample/demo.

Show below is the first two screens of the documentation:


Here is the output of the demo code, which will be presented in this and following posts.


which is calculated from the following sample data, which is a daily measurement of my body weight for a week.  (as an aside I have lost 157 pounds over the past year and I will be using data I have collected during that time as sample data for this program)

Here is the hard coded assignment of the data, in future coding the data will be read from a text file and converted to real numbers)

stat01-2 data

The data is stored in an ARRAY of Real – called SD[], SD[0] – holds the sample size and SD[1] to SD[7] holds the data in time ordered fashion.

I will later provide a full listing of the source code, in the mean time here are the code snipets for calculating the sum of the data and then then mean, along with displaying it to the screen.  The GOTOXY(X,Y) is in the include file CONIO.P and REALTOSTR() function converts a real number from scientific notation to a decimal string format, for easier viewing.  To calculate the sum a for loop from one to n=7 is used and each element of the array is added to the running total, also an array SA[] is a copied from SD[] and will be used later to have a sorted copy for finding the minimum, maximum, median and to be used in the Anderson-Darling normality test.

Then from the sum the mean (xbar) is calculated by dividing the sum by n (7 in this case) and all are printed to the screen, using the GOTOXY and REALTOSTR calls.

stat01-3 - sumstat01-4 mean

The next post will pick up with sorting the array, calculation of Standard Deviation, Variance, Skewness and Kurtosis.






Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s