Preliminaries
Download the following three files onto your desktop.
- The CS105 input/output teachpack:
cs105_io.ss - The weights in pounds of all baseball players who made their major league
debut in the fifties:
W50s.txt - The weights in pounds of all baseball players who made their major league
debut in the nineties:
W90s.txt
This cs105_io.ss teachpack provides two functions:
;; write-to-file: list-of-num string -> string
read-from-file takes one argument: a string
which is the name of a data file. That file is read into a list
of number, one number at a time.
We will not use the function write-to-file this
afternoon; it works similarly.
Your Assignment
Part I
At the top of the definitions window, provide a data definition for
.
Write Scheme definitions for count (which should give the
number of elements in a list), sum, mean,
variance and stdev (standard
deviation). Provide contracts, purposes and
test cases for each.
There are different ways of defining variance and standard deviation in the realm of statistics. For this lab, please adhere to the following definitions.
- The variance of a set of numbers is the is the mean of the squares minus the square of the mean.
- The standard deviation is the square root of the variance.
Part II
Once all of your functions are working properly, use them, together
with the teachpack function,
to analyze the given baseball data. Your results should correspond to
the numbers in the Benchmarks section below.
You will need to feed full pathnames to read-from-file when
you call it. The full pathnames of the data files on your desktops will be of the form
Extra Credit
Write median.
Benchmarks
To make sure your numbers are not way off base, here are a few ballpark figures to check against your results:
- the 50s mean weight is about 186
- the 90s mean weight is about 193
- the 50s variance is about 246
- the 90s standard deviation is about 19
Hand in your work.
Submit your work to Chalk according to the following instructions.