r markdown A fair coin has a probability 0.5 of landing heads up. Suppose this c
ID: 3589396 • Letter: R
Question
r markdown
A fair coin has a probability 0.5 of landing heads up. Suppose this coin is tossed 100 times.
1. Use rbinom function to generate the number of heads in 100 tosses, denoted as heads. What is the relative frequency of heads in your simulation? (Hint: 100 tosses is equivalent to 1 randomly generated binomial as long as you choose the parameters correctly),
2. Repeat the above step 1000 times; store all the 1000 heads values into a vector runs(Hint: Repeating the 100 tosses 1000 times is equivalent to generating 1000 binomials).
3. Draw a density histogram of vector runs with proper axes names.