Download Homework 10: Statistical Analysis of Bacterial Growth and Monte Carlo Simulation and more Assignments Statistics in PDF only on Docsity! Homework 10 Assigned: 11 November 2005 Due: 21 November 2005 C:\baileraj\Classes\Fall 2005\sta402\hw\Homework-10-11nov05.doc 1. USE IML to perform a randomization test of the log(bacterial growth) data under the 4 meat packaging conditions. In this problem, we have n1= n2= n3= n4=3. Use a statistic that measures the difference in the 4 group means, e.g. CSS = (∑ − = 4 1 2 . i i YY ) where iY is the arithmetic mean of the ith group and .Y is the mean of all of the observations. As an aside, it might be interesting to compare the CSS statistic to another statistic, e.g. the maximum difference in means ]1[]4[ YYD −= where ]4[Y is the largest sample mean and ]1[Y is the smallest sample mean ([i] is a common notation for order statistics). NOTE: this is a redo of a HW 7 problem. 2. Write an IML module to conduct a small Monte Carlo simulation to show that how confidence interval for the mean of an exponential distribution based upon Y ± t(1-α/2, n-1) sY/√n performs when estimating the mean of an exponential distribution. Select at least 3 values of “n” for this illustration (say n=15, 30, and 50). Comment: You can generate exponential random variables a couple of different ways in IML. You can use “ranexp” (yep, it still works here) – see “mran_exp”. This module generates a random exponential (mean=1) and multiplies it by lambda to get a random exponential (mean=lambda). Alternatively, you can use an inverse transformation to generate the exponential data see “mran_exp2.” An exponential random variable with mean lambda has a p.d.f f(x) = (1/lambda)*exp(-x/lambda) for x>0 and c.d.f. F(x) = 1 – exp(-x/lambda). If you generate a Uniform random variable, then you can use this to generate an exponential random variable. Given u~Unif(0,1), x = -lambda*log(1-u) ~ Exp(lambda). This works because you are equating a random uniform value with the c.d.f. of the exponential and then solving for the x associated with this value. Example modules are given below. options nocenter nodate formdlim="-"; proc iml; start mran_exp(lambda,nvar,seed,mout); /* ----------------------------------------------- */ /* module I: generate exponential random variables */ /* ----------------------------------------------- */ mout = J(nvar,1,0); do i=1 to nvar; mout[i,1] = lambda*ranexp(seed); end; finish; *-------------------------------------------; call mran_exp(6,20,0,temp); mean_temp = temp[+,1]/nrow(temp); ttemp = T(temp); print ttemp; print mean_temp; TTEMP COL1 COL2 COL3 COL4 COL5 COL6 COL7 ROW1 21.529452 8.7223396 1.5004195 8.724612 1.4393328 6.0519376 0.1558697 COL8 COL9 COL10 COL11 COL12 COL13 COL14 ROW1 16.69032 15.81354 5.8161484 13.218309 5.4059908 3.0421653 3.4291513 COL15 COL16 COL17 COL18 COL19 COL20 ROW1 19.885634 0.7816278 0.2744662 3.1538596 1.0421681 0.4316474 MEAN_TEMP 6.8554495 start mran_exp2(lambda,nvar,seed,mout); /* ------------------------------------------------ */ /* module II: generate exponential random variables */ /* ------------------------------------------------ */ mout = J(nvar,1,0); do i=1 to nvar; mout[i,1] = -lambda*log(1-uniform(seed)); end; finish; *-------------------------------------------; call mran_exp2(2,20,0,temp2); mean_temp2 = temp2[+,1]/nrow(temp2); ttemp2 = T(temp2); print ttemp2; print mean_temp2; TTEMP2 COL1 COL2 COL3 COL4 COL5 COL6 COL7 ROW1 3.874145 3.911329 0.1175599 0.5268964 0.9169826 1.6086105 0.4182267 COL8 COL9 COL10 COL11 COL12 COL13 COL14