{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw9sol - IEOR 4404 Simulation Prof Mariana Olvera-Cravioto...

This preview shows pages 1–2. Sign up to view the full content.

IEOR 4404 Assignment #9 Solutions Simulation 28th November 2006 Prof. Mariana Olvera-Cravioto Page 1 of ?? Assignment #9 Solutions 1. (a) X ( n + 1) = 1 n +1 n +1 i =1 X i = 1 n +1 ( n i =1 X i + X n +1 ) = 1 n +1 ( n X ( n ) + X n +1 ) = X ( n ) + X n +1 - X ( n ) n +1 . And, to prove the second equality, note that: S 2 ( n +1) = 1 n [ n +1 i =1 ( X i - X ( n +1)) 2 ] = 1 n [ n +1 i =1 X 2 i - ( n +1) . X 2 ( n +1)] = 1 n [ n i =1 X 2 i + X 2 n +1 - ( n + 1) × [ n n +1 ( X ( n ) + X n +1 ) 2 ]. Continuing from here with some algebra (expanding and regrouping terms), we get: S 2 ( n + 1) = (1 - 1 /n ) S 2 ( n ) + 1 n +1 [ X ( n ) - X n +1 ) 2 ]. But, X ( n + 1) - X ( n ) = 1 n +1 ( X n +1 - X ( n )). Therefore, ( X ( n + 1) - X ( n )) 2 = 1 ( n +1) 2 ( X ( n + 1) - X ( n )) 2 . And, S 2 ( n + 1) = (1 - 1 /n ) S 2 ( n ) + ( n + 1)( X ( n + 1) - X ( n )) 2 . (b) The following code asks the user to input a vector of data and then computes the sample mean and standard deviation using the recursive formulas above. data=input(’\n Enter data vector:’) n=length(data); xBar(1)=data(1); sSq(1)=0; for i=1:n-1 xBar(i+1)=xBar(i)+(data(i+1)-xBar(i))/(i+1); end for i=1:n-1 sSq(i+1) = (1-1/i)*sSq(i)+(i+1)*(xBar(i+1)-xBar(i))^2; end xBar(n) sSq(n) 2. (a) Knowing that S 2 ( n )

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

hw9sol - IEOR 4404 Simulation Prof Mariana Olvera-Cravioto...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online