Suppose that your boss instead asks that you toss a fair coin six times, record the number of heads, and then repeat the process, for 2000 times in total. How might you simulate this process with a U(0,1) random number generator? Try to generate the outcome for each group of six tosses at once (i.e., use 2000 random numbers, rather than 12,000 individuals outcomes which you bundle into groups of size six).
Let, X denotes number of heads in 6 tosses of fair coin
We have to repeat this process 2000 times. We want such 2000 values of x using U(0,1) variable
First, select 2000 uniform(0,1) variates, let they are, y=(y1,y2, .................,y1999,y2000)
Now, treat them as the probabilities, now we will get values of binomail variable X(i) such that probability of X(i) is yi where X(i) is number of heads in 6 tosses of fair coin at i'th process
Here is the R code for same
y=runif(2000,0,1) # It gives 2000 random values between 0 and
1
X=qbinom(y,6,0.5) # It gives 2000 values of X, where X is defined
above, here in binomail random variable, n=6, p = 0.5 and X is the
assumed value whose probability is y
Get Answers For Free
Most questions answered within 1 hours.