The goal of this problem is to simulate a geometric random


The goal of this problem is to simulate a geometric random variable (which will be covered on Friday, Feb 6th in lecture). We will break this problem into two parts.

Part a

Build a function which takes in p. This function should repeat a Bernoulli trial until a "success" (defaulted to a 1 in R) occurs, and return the trial number on which the first success occurred (i.e., if the 3rd trial resulted in a "success", this function should return 3). Use your function with the following values of p (and show your functions output):

i.p=0.02 ii.p=0.10 iii. p = 0.50

Part b

Build another function which takes in p, r, and N. This function will calculate the probability that the first "success" occurred on the rth trial, based on N simulations.

Notice you can use your function from Part a in this function.

Use your function with the following values of p, r, and N (and show your functions output):

i. p = 0.02, r = 10, N = 600000
ii. p = 0.10, r = 10, N = 600000
iii. p = 0.20, r = 10, N = 600000

These simulations may take a few minutes (or more depending on your computer) to run, but they should not crash your computer.

Remember that you can always use the computer labs to complete simulations.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: The goal of this problem is to simulate a geometric random
Reference No:- TGS01040335

Expected delivery within 24 Hours