

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
The solutions to quiz 1 for math-338, which involves simulating the outcome of rolling a fair die and tossing a fair coin using r. The r code for simulating 1,000,000 rolls of a die and 1,000,000 tosses of a coin, as well as the analysis of the results. The document also compares the simulation results with the theoretical probabilities of the binomial distribution.
Typology: Quizzes
1 / 3
This page cannot be seen from the preview
Don't miss anything!
(1) Simulations with R: Suppose that we want to simulate 10 times rolling a fair die. We can use this simple command:
round(runif(10,0.5,6.5)) [1] 2 3 5 2 2 3 6 5 6 1
I got three 2s, two 6s, two 5s, two 3s, and one 1. (1) Simulate 1,000,000 rolling of a fair die. Tally your findings. Provide tables of summaries. Make a comment regarding the big picture behind your simulation results.
a=round(runif(1000000,.5,6.5)) for(i in 1:6)
{
for(i in 1:2)
(3) Simulate 1000,000 observations from a binomial distribution with probability of success p = 0.6 and the number of trials n = 4. Then using the simulation results, answer the following questions: P r(X ≥ 2) P r(X = 0) P r(X ≤ 2) Next, compare your findings from the simulation study with the actual proba- bilities of the binomial distribution. In other words, calculate the above three probabilities using dbinom and pbinom. This is the power of simulation. Simulations:
c=rbinom(1000000,4,0.6) length(c[c>=2])/ [1] 0. length(c[c==0])/ [1] 0. length(c[c<=2])/ [1] 0. Theoretical: 1-pbinom(1,4,0.6) [1] 0.