
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
An assignment for a statistics course (stat 243) from the fall, 2009 semester. Students are required to write programs to calculate the mean and variance using three different methods: desk calculator algorithm, method of provisional means, and centering around the first observation. They are also asked to generate uniform and normal random numbers, and test the accuracy and efficiency of their programs. The assignment includes hints and notes for each problem.
Typology: Assignments
1 / 1
This page cannot be seen from the preview
Don't miss anything!

due November 9, 2009
Write a program to calculate the mean and variance using the following three different meth- ods: (a) Desk Calculator Algorithm (b) Method of Provisional Means (c) Centering around the First Observation Test your program using numbers of your choice, and verify your answer using a program such as R, SAS, matlab, or a routine from the lapack libraries.
Construct a sequence of data sets such that the coefficient of variation (std. deviation / mean) becomes increasingly smaller. Continue your sequence until one or more of the algorithms in part 1 no longer gives correct answers. At what value of the coefficient of variation do you begin to see problems? At what value of the coefficient of variation does the calculation break down completely? Hint: You can generate the sequence you need by adding a progressively larger constant to any set of numbers.
Write a function to generate uniform random numbers in the range of 0 to 1. Use a multi- plicative congruential generator, with modulus 2^32 , and a value of your own choosing for a (but make sure mod(a,8) is 3 or 5.) Calculate the mean and variance for several sequences of numbers from your generator, using one of the programs written for part 1. What is the theoretical value of the mean and variance for a uniform distribution from 0 to 1? How do your observed values compare to these values?
Write a program to generate normally distributed random numbers with mean 0 and variance 1 by a) using the Polar method, and b) adding together six uniform random numbers. Ex- amine the means, variances, minimums and maximums from each of ten samples from each method to insure that they look reasonable. Compare the time it takes to generate normal random variables by the two methods. Note: In order to time a program, you can use the system call getrusage(). To make things easier, look at the file timer.h in ../s243/samples.
Using one or more of the methods described in class, test your random number generator or the random generators from R, matlab, SAS, or some other source.