4. Introduction to Lists and Using Programming Principles: Homework

Author: YourNameGoesHere

Last revision:  January 15 1998

Preliminary defintions

Evaluate these cells before proceeding the the rest of the assignments.

numStuds = 15;
roster = 
{"Carr", "Crabtree", "Davis", "Dixon", "Herbert", "Jones", "Moore", "Moskowitz", "Naples", "Phillips", "Rice-Stitt", "Schenk", "Seifert", "Slaby", "Tarver"};

Clear[draw,n]
draw[n_]:=Length[
  Union[
    Table[ roster[[ Random[Integer,{1,numStuds}] ]],
      {n} 
    ]
  ]
]

Clear[aveDraw,n,trials]
aveDraw[n_,trials_] := 
	 N[ Sum[ draw[n], {trials} ] / trials ]

Calling On Students

1.  If ten random names are called each day, how many different people are likely to be called on?

2.  How many random names should be called so that, on average, fifteen different people get called?

3.  If we use several trials for our simulation (using "aveDraw[]" instead of "draw[]"), why is the resulting graph less fuzzy?

Calling On Fractions

Suppose now that, instead of selecting random names from a list, we simply choose fractions which have numerators chosen randomly from 1 to 1000 and denominators chosen randomly from 1 to 3.

1.  Generate a random integer between 1 and 1000.

2.  Generate a random integer between 1 and 3.

3.  Generate a random integer between 1 and 1000 and a random integer between 1 and 3, using the first for a numerator and the second for a denominator of a rational number.  Convert the fraction to an approximate value.

4.  Generate a list of ten such approximate values.

5.  The "Max[]" function returns the largest number appearing in a list.  Use it to get the largest number from a list of ten such approximate values.

6. Write a function "max1000[]" that gives the maximum value from a list of "n" approximate values representing fractions with numerators chosen randomly from the integers 1 to 1000 and denominators chosen randomly from the integers 1 to 3.

7.  Produce a graphical representation of "max1000[]".  (Use "ListPlot[]".)

8.  What's the average value of "max1000[25]" when the command is executed thirty times?

9.  Write a function "ave1000[n]" that computes the average of thirty trials of "max1000[n]".

10.  Produce a graphical representation of "ave1000[]".