/*

      stats - Numerator program to calculate some statistical
              information about a sample

          Set the verbose variable to a non-zero value 

               verbose = 1

          to make queries and produce other prompts.  
*/


if (verbose) 
   "Enter next number\n"
   "Enter 0 to end list\n"
endif
get val                                /* First, collect and calculate*/
if (val)                               /* the mean and the sum of the */
   meantot = meantot + val             /* squares of the numbers      */
   sqtot = sqtot + (val ^ 2)           /* listed                      */
   items = items + 1
   do "stats"
endif
mean = meantot / items
deviation = sqrt ((sqtot - items * (mean ^ 2)) / items)
deviationS = sqrt ((sqtot - items * (mean ^ 2)) / (items - 1))
variance = deviation ^ 2
varianceS = deviationS ^ 2
"Mean is            "; mean
"Standard deviation (pop)"; deviation
"Variance           (pop)"; variance
"Standard error     (pop)"; deviation / sqrt (items)
"Standard deviation (sam)"; deviationS
"Variance           (sam)"; varianceS
"Standard error     (sam)"; deviationS / sqrt (items)

