Starting from:

$25

CSC632-Homework 2 Solved

Introduction to Simulation and Modeling, CSC 432/632           

Assignment 2  

Chapters 4, 5, 6, 7  

(Total of 10 points, problems 3 and 5 two points and all other problems 1 points) 

Chapter 4:  

1-      Use the section “Applying the Monte Carlo method for Pi estimation” on Page 91 of the book and use Python codes to calculate Pi. NOTE: Instead of ¼ of the circle (depicted in Figure 4.2), use half (1/2) of the circle and redo the exercise accordingly.

a.       Repeat the Python code using N = 100, 1000, 10000. Explain about the initial value and the role of Large Numbers in the calculation of Pi number. Explain all the codes, all functions, and different methodology in Python.   

b.      Re-do the plot of the Pi estimation in Figure 4.3 for the half circle. Provide three figures for different cases where N = 100, 1000, 10000. Explain all the codes. Explain how the increasing number of N changes the figures.

2-      Estimate the expected value of a random variable as established by the law of large numbers in Page 97. To this end, generate 10,000 random numbers with a uniform distribution and then extract 100 samples from this population, also taken randomly (resulting in samples with 1000 numbers). (Note that in the book we had vice versa and had 1000 samples). Repeat this operation for a consistent number of times and store the results in a vector. Finally draw a histogram of the distribution that we have obtained. Compare your result with the figures in the book and explain which approach better explains the central limit theorem.        

3-      Use the integration methodology using Monte Carlo in Page 104 to calculate the following two integrals. In addition, use Visual representation method in Page 112 to draw the Plot of numerical integration results.  

a.       𝐼 = ∫"! 2𝑥/(2 − 𝑥)  𝑑𝑥

b.      𝐼 = ∫$# 𝑥#   𝑑𝑥

Chapter 5: 

4-      Using P=0.45, P=0.5, and P=0.55 and redo the simple random walk in Page 130-132 for each value of P. Draw the trend plot of the random walk and provide explanations about each trend and the impact of P in the trend.  

5-      Simulating weather forecast according to the following probability values.  

P(Sunny| Sunny)=0.75, P(Sunny| Rainy) = 0.25  

P(Rainy| Sunny)=0.3 P(Rainy| Rainy) = 0.7  

a.       Plot the weather forecast for the next 365 days.  

b.      Draw the histogram of the weather forecast.

c.       Draw a histogram for the weather forecast for different days of the week. You can draw one histogram for the number of sunny days during different days of the week and another histogram for the number of rainy days during days of the week. You can also combine and use two bars (one for rainy and one for sunny days) during a week. Is there any difference among different days?  

Chapter 6:  

6-      (Jackknife resampling) Do the resampling of 250 and 500 randomly generated values and calculate the coefficient of variation. Report the correlation of variation in different stages of the resampling. Use two different number of samples (N) in the starting distribution (according to the number of values). Explain what Pseudo value is in the resampling method described in the Jackknife resampling method. Draw the distribution of pseudo values.  

Chapter 7:  

7-      Using the Gradient Descent algorithm in Python calculate the maximum/minimum value of  

𝑦 = −3𝑥% − 5𝑥 + 2

a)      Explain about the learning rate variable. Try 0.1, 0.5, and 0.01 and compare the results.

b)      List the last 10 values of y in the iterations.  

c)      Now imposing a restriction on x, and having a new feasible set, calculate the following optimization problem.

𝑦 = −3𝑥% − 5𝑥 + 2

𝑠.   

8-      In one paragraph explain how does the Newton-Raphson method work

a)      Using this method find the optimal value of the same function as the above example. Explain the details.

𝑦 = −3𝑥% − 5𝑥 + 2

b)      Draw the maximum/minimum point of the function.  

c)      In how many iterations did you find the results. Compare the performance with the Gradient descent algorithm in Problem 7.  

More products