Starting from:
$30

$24

Final : Lab Take-home

Your solutions should contain clearly identified numerical answers and well labeled tables/figures, where appropriate. Make sure to include clear and concise interpretations (that is, clear, full sentences) of any values, figures, and responses to queries posed. Place all code in an appendix, at the end of your solutions document.

1. Roulette wheel simulation: A roulette wheel has 38 slots of which 18 are red, 18 are black, and 2 are green. If a ball spun on to the wheel stops on the color a player bets, the player wins. Consider a player betting on red. Game streaks follow a Geometric(p=20/38) distribution derivation of the Geometric distribution from the Bernoulli distribution to simulate the game. Namely, generate Bernoulli (p=20/38) random variates until a black or green occurs. Run 1000 simulations and report the following:

a) What was the longest game streak until a loss?
    

b) Plot the histogram of game streak lengths
    




c)  Average of the game streaks
    
d) Variance of the game streaks
    

e) Compare (c) and (d) to the true mean and variance from a Geometric distribution with p = 20/38

2. Simulating negative binomial distributions: Recall that a negative binomial random variable NegBin(r,p) is the sum of r Geometric(p) random variables. Suppose the player from the first problem decides to play until the player loses 10 times (i.e., until we get 10 black or green spins). Modify the algorithm in problem 1 to simulate 1000 NegBin(10, 20/38) random variates and report the following:

    a) What was the longest game streak until 10 black or green spins?
    
b) Plot the histogram of the game streak lengths
    

c) Average of the game streaks
    
    d) Variance of the game streaks
        
e) Compare (c) and (d) to the true mean and variance from a Negative Binomial distribution with r = 10 and p = 20/38.

3. Recall that the Linear congruential generator is defined as 
                
a) Plot a histogram of your variates 

b) Draw the empirical CDF of your variates against the true CDF of a uniform distribution
    

c) Perform your Kolmogorov-Smirnov test to validate your random number generator. Do your pseudorandom numbers seem to follow a uniform distribution? Base your conclusions from the test at an α = 0.05 

    
    





















4.   Simulating Normal probabilities. Finding areas under the normal curve is analytically quite difficult to the form of the pdf. We can use Monte Carlo estimates via simulation. One such method is the Box-Müller algorithm. This simulator applys a transformation method to convert uniform variates into normal variates by generating two random variates Z1 and Z2 from a N(0,1) distribution. The Box-Müller steps to simulate a normal distribution with mean μ and variance σ2 are as follows: 
i. Generate U1,U2 ∼ U(0,1), two uniform random variates
    

ii. Compute Z1 =   =  
    
iii. ComputeX1 =σZ1+μandX2 =σZ2+μ. 


Use the Box-Müller algorithm to simulate 1000 random variates of X1 and 1000 random variates of X2 that follow a normal distribution with μ = 2 and σ2 = 2, i.e. X1 ∼ N(2,2). Then report the following: 
a) The mean, variance, and median of the combined variates of X1 and X2






b) Histogram of these combined variates and an overlay with the true density
        
        
c) Find the proportion of simulated values of these combined variates that lie within one, two, and three standard deviations from the mean (i.e., they are within µ ± σ, µ ± 2σ, and µ ± 3σ). These percentages are estimates of P(u − iσ < X < µ + iσ) for i = 1, 2, 3.
    


d) The true values of the three probabilities in c are 0.68, 0.95, and .997, respectively. This is known as the Empirical rule or “68-95-99.7” rule. Compare your estimates from (c) to these true values
    
    

More products