HW8_solution

pdf

School

University of Texas *

*We aren’t endorsed by this school

Course

440

Subject

Industrial Engineering

Date

Jan 9, 2024

Type

pdf

Pages

11

Uploaded by surker21

Report
CEE 373 Homework #8 Due date: November 10 at 5pm Total: 100 points 1. (40 points) [Computer required] Before solving this problem, please review the starter code: https://colab.research.google.com/drive/1Qg2waI348FMSqB5cRJv1O2mj9CwpWzHP? usp=sharing Let’s revisit your monthly salary as a newly graduated engineer with your E.I.T. certification in hand from last homework. Again, the starting salary for graduate engineers with their E.I.T. certification is uniformly distributed between $ 70,000 to $ 110,000 per year. You are still interested in X , which is 30% of your monthly salary. Now, you will answer questions about X using Monte Carlo Simulation. (a) Generate 1,000,000 samples of X . Plot these samples in a histogram in comparison with the PDF of X . (b) Consider Y to be the monthly amount your potential roommate can put towards rent. This is independent and identically distributed to X . You are again interested in your combined monthly salary that can go to- wards rent, Z = X + Y . Using Monte Carlo Simulation, generate 1,000,000 samples of Z . Plot a histogram of these samples with the PDF of Z (you already calculated the PDF in HW7). (c) Using your Monte Carlo simulation results, calculate the probability of Z being greater than or equal to $ 4000 ( P ( Z 4000)). Compare this to the probability you calculated in Homework 7. (d) You believe your sample mean is equal to the true mean of X when you draw multiple samples from X . Employ the Central Limit Theorem (CLT) to cal- culate the true mean ( µ X ) and standard deviation ( σ X ) of the sample mean ( X ) for the following sample sizes: n = { 1 , 2 , 10 , 30 , 300 } . This calculation can be done by hand. (e) For each of the specified sample sizes, n = { 1 , 2 , 10 , 30 , 300 } , perform the following steps. 1. Generate n samples of X 2. Calculate the sample mean X 3. Repeat (1) and (2) k = 1 , 000 times 4. Plot a histogram of your results from (1) - (3) and compare this to the normal PDF using the calculated respective mean and standard deviation from part (e) What do you observe about the comparison between the histogram and the Normal PDF for all values of n ? Page 1 of 11
CEE 373 Homework #8 (f) Do the same as part (e), now using an exponential distribution, E , with λ = 0 . 25 instead of X (g) Now consider that your roommate and your combined income is T = cos 3 ( xy )+ sin ( y ). Using Monte Carlo Simulation, obtain the PDF of T, f T ( t ) and plot. Solution: This is the solution code ( https://colab . research . google . com/drive/1LNI39Lf95pUZTo2M1xLyaIEPHJ sharing ) for the answers and figures. (a) The density histogram of Monte Carlo simulation with 1,000,000 samples and PDF of X. (b) - PDF of Z from the HW 7: f ( z ) = ( 0 . 001 1000 ( z 3500) (3500 z 5500) 0 . 001 1000 ( z 5500) (4500 < z 5500) - Monte Carlo simulation Draw 1,000,000 samples of X and Y from the uniform distribution. X Uniform (1750 , 2750) , Y Uniform (1750 , 2750) Z values are the sum of X and Y sampling values. When drawing PDF and density histogram of samples, Page 2 of 11
CEE 373 Homework #8 The shape of density histogram is close to the PDF of Z. (c) - Using PDF: P (4000) = Z 5500 4000 f ( z ) dz = 0 . 875 ( See HW 7 solution ) - Using Monte Carlo simulation: P ( Z 5000) = the number of samples higher than 4000 the number of total samples 0 . 875 (The values can be different, but it should be close to 0.875). (d) The mean of PDF: E ( X ) = µ X = Z 2750 1750 xf ( x ) dx = 2250 The variance of PDF: V ar ( X ) = σ 2 X = Z 2750 1750 ( z µ X ) 2 f ( x ) dx = 288 . 68 2 The mean of sample mean: µ X = µ X = 2250 Page 3 of 11
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
CEE 373 Homework #8 µ X does not depending on the sample sizes. The standard deviation of sample mean: σ X = r V ar ( X ) n = 288 . 68 n When n = { 1, 2, 10, 30, 300 } , the value of σ Z is 288.68, 204.12, 91.29, 52.70, and 16.66 for each n. (e) -If n = 1 , make 1,000 sample sets having one sample and calculate the sam- ple mean value for each sample set. The theoretical PDF X would be close to Normal(2250, 288.68 2 ). -If n = 2 , make 1,000 sample sets having two samples and calculate the sam- ple mean value for each sample set. The theoretical PDF X would be close to Normal(2250, 204.12 2 ). -If n = 10 , make 1,000 sample sets having ten samples and calculate the sample mean value for each sample set. The theoretical PDF X would be close to Normal(2250, 91.29 2 ). -If n = 30 , make 1,000 sample sets having thirty samples and calculate the sample mean value for each sample set. The theoretical PDF X would be close to Normal(2250, 52.70 2 ). -If n = 300 , make 1,000 sample sets having three hundred samples and calculate the sample mean value for each sample set. The theoretical PDF X would be close to Normal(2250, 16.66 2 ). When n increases, the shape of density histogram is close to the normal dis- tribution. Page 4 of 11
CEE 373 Homework #8 (f) The exponential distribution with λ = 0 . 25: f ( x ) = λ exp λ x = 0 . 25 exp 0 . 25 x The mean of PDF: E ( X ) = µ X = Z inf 0 xf ( x ) dx = 4 The variance of PDF: V ar ( X ) = σ 2 X = Z inf 0 ( z µ X ) 2 f ( x ) dx = 4 2 The mean of sample mean: µ X = µ X = 4 µ X does not depending on the sample sizes. The standard deviation of sample mean: σ X = r V ar ( X ) n = 4 n When n = { 1, 2, 10, 30, 300 } , the value of σ X is 4, 2.83, 1.26, 0.73, and 0.23 for each n. -If n = 1 , make 1,000 sample sets having one sample and calculate the sam- ple mean value for each sample set. The theoretical PDF X would be close to Normal(4, 4 2 ). -If n = 2 , make 1,000 sample sets having two samples and calculate the sam- ple mean value for each sample set. The theoretical PDF X would be close to Normal(4, 2.83 2 ). -If n = 10 , make 1,000 sample sets having ten samples and calculate the sample mean value for each sample set. The theoretical PDF X would be close to Normal(4, 1.26 2 ). -If n = 30 , make 1,000 sample sets having thirty samples and calculate the sample mean value for each sample set. The theoretical PDF X would be close to Normal(4, 0.73 2 ). -If n = 300 , make 1,000 sample sets having three hundred samples and calculate the sample mean value for each sample set. The theoretical PDF X would be close to Normal(4, 0.23 2 ). Page 5 of 11
CEE 373 Homework #8 When n increases, the shape of density histogram is close to the normal dis- tribution. (g) Using the 1,000,000 samples for X and Y, T can be calculated. The density histogram of T: 2. (20 points) A city is located at the downstream of the confluence point of two rivers as shown. The annual maximum flood peak in River X has an average of 25 m 3 sec with the standard deviation of 20 m 3 sec , whereas in River Y the mean peak Page 6 of 11
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
CEE 373 Homework #8 flow rate is 30 m 3 sec and the standard deviation is 10 m 3 sec . The annual maximum peak flow rates in both rivers are normally distributed with a correlation coefficient of 0.5. Presently, the channel which runs through the city can accommodate up to 100 m 3 sec flow rate without flooding the city. (a) What are the mean and standard deviation of the annual maximum peak discharge passing through the city? (b) What is the annual risk that the city will experience flooding based on the existing channel capacity? What is the corresponding return period (i.e. how often will a flood reoccur)? (c) Calculate the probability that the city will experience flooding over a 10-year period. Solution: (a) Let Q 1 and Q 2 be the annual maximum flood peak in rivers 1 and 2, respec- tively. Tha annual max. peak discharge passing through the city, Q, is the sum of them, hence µ Q = µ Q 1 + µ Q 2 = 25 + 30 = 55 m 3 /secσ 2 Q = σ 2 Q 1 + σ 2 Q 2 + 2 ρ Q 1 Q 2 σ Q 1 σ Q 2 = 10 2 + 20 2 + 2 0 . 5 20 10 = 700 m 3 /secσ Q = 26 . 46 m 3 /sec (b) The annual risk of flooding, p = P ( Q > 100) = 1 Φ( 100 55 26 . 46 ) = 1 Φ(1 . 7) = 1 0 . 955 = 0 . 0446 this is the probability each year, hence the return period is τ = 1 /p = 1 / 0 . 0446 = 22 years (c) Since the yearly risk of flooding is p = 0 . 0446, and we have a course of n = 10 years, we adopt a binomial model for X, the total number of flood years over a 10-year period. Hence the probability of city experience any flooding would be: P ( any flooding ) = 1 P ( no flooding ) = 1 P ( X = 0) = 1 (1 p ) 10 = 1 (1 0 . 0446) 10 = 1 (1 0 . 0446) 10 = 0 . 366 Page 7 of 11
CEE 373 Homework #8 3. (40 points) [Computer required.] Note, this problem does not have specific starter code but you can build on the starter code from this homework. The focus of this problem is to sample from correlated distributions. Consider a similar problem to problem 2, now with calculations done on the computer. (a) Generate 10,000 samples from River X ’s distribution and plot their density histogram. (b) Given your answer for part (a), sample 10,000 points from River 2’s distribu- tion. Note, you cannot sample directly from Y when it is correlated with X . Because X and Y are correlated, any random sample of Y must depend on its corresponding value of X . Since the variables are dependent, the mean and standard deviation for River Y are given by: µ Y | X = µ Y + ρσ Y σ X ( x µ X ) σ Y | X = σ Y p 1 ρ 2 This means you first have to generate random numbers for X and then use the above equations to calculate the corresponding mean and standard deviation of Y . Once you calculate those, you can sample from the normal distribution as you usually would. Plot the density histogram for River Y. (c) Plot your answer for part (a) versus part (b). You can use the plot.scatter(X,Y) function in Python to create a scatter plot. Comment on what you observe about the relationship between X and Y . (d) Plot the density histogram of the total flow into the city: Z = X + Y (e) Estimate the mean and standard deviation of the annual maximum peak discharge passing through the city. (f) Using your values for Z , calculate the probability that the city will experience flooding. Solution: This is the solution code ( https://colab . research . google . com/drive/ 1LNI39Lf95pUZTo2M1xLyaIEPHJAYs99j?usp=sharing ) for the answers and figures (a) - Density histogram of X from the generated 10,000 samples: Page 8 of 11
CEE 373 Homework #8 (b) From the every X value, you can get one µ Y | X . Therefore, in this case having 10,000 of X samples, you have 10,000 µ Y | X values. But the σ Y | X value is same for every X sample. Y i sample from X i ( i th sample) comes from the normal distribution having µ Y i | X i and σ Y i | X i . Y i Normal ( µ Y i | X i , σ 2 Y i | X i ) After sampling of Y and drawing a density histogram of them: (c) - Scatter plot of X samples and Y samples: Page 9 of 11
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
CEE 373 Homework #8 (d) We can make Z samples from the sum of X and Y samples. - Density histogram of Z (e) The sample mean of Z is: ¯ Z = 1 n n X i =1 x i = 54 . 73 The sample variance of Z is: s 2 = 1 n 1 n X i =1 ( x i ¯ x ) 2 = 26 . 61 2 (1) Therefore, sample standard deviation of Z is 26.61. (This answer can be different between students, but it need to close to the mean and standard deviation value above.) Page 10 of 11
CEE 373 Homework #8 (f) P ( Z > 100) = num. samples higher then 100 num. total samples = 0 . 046 (This answer can be different between students, but it need to close to 0.046.) Page 11 of 11