Question

In: Computer Science

USE R-studio TO WRITE THE CODES! # 2. More Coin Tosses Experiment: A coin toss has...

USE R-studio TO WRITE THE CODES!

# 2. More Coin Tosses
Experiment: A coin toss has outcomes {H, T}, with P(H) = .6.
We do independent tosses of the coin until we get a head.

Recall that we computed the sample space for this experiment in class, it has infinite number of outcomes.

Define a random variable "tosses_till_heads" that counts the number of tosses until we get a heads.
```{r}

```

Use the replicate function, to run 100000 simulations of this random variable.
```{r}

```
Use these simulations to estimate the probability of getting a head after 15 tosses. Compare this with the theoretical value computed in the lectures.
```{r}

```
Compute the probability of getting a head after 50 tosses. What do you notice?
```{r}

Solutions

Expert Solution

Answer:

Defining and running 100000 simulation of the random variable "tosses_till_heads" using replicate() function

> set.seed(666)
> tosses_till_heads=replicate(100000,(rgeom(1,0.6)+1))
> # 1st 10 values
> head(tosses_till_heads,10)
 [1] 1 2 1 1 1 3 1 3 1 1

Using the simulation to estimate the probability of getting a head after 15 tosses i.e P[ tosses_till_heads>15] and comparing this with the theoretical value i.e (1-0.6)15 .

> #Probability of getting a head after 15 tosses
> 
> sum(tosses_till_heads>15)/100000
[1] 0
> 
> # Theoretical value of the probability
>  
> (1-0.6)^15
[1] 1.073742e-06

Clearly the theoretical value is slightly higher than the empirical/ estimated probability.

> #Probability of getting a head after 50 tosses
> sum(tosses_till_heads>50)/100000
[1] 0
> 
> # Theoretical value of the probability
> 
> (1-0.6)^50
[1] 1.267651e-20

The estimated probability is 0 for this case as well but the theoretical probability is almost equal to zero and almost equal to the estimated value of the probability.

Conclusion:Therefore as the no of tosses to get 1st head increase the estimated value of the probability comes closure to the theoretical value.


Related Solutions

Using R-studio 2. Consider an experiment where we flip a fair coin six times in a...
Using R-studio 2. Consider an experiment where we flip a fair coin six times in a row, and i is the number of heads tossed:             a.         Calculate the probability mass function for i = 0. . . 6 using the equation from Ross section 2.8 for Binomial Random Variables             b.         Conduct a simulation of this experiment in R, with T trials of the experiment – pick several values of T from 10 to 10,000.             c.         Create a...
COIN TOSSES In a large class of introductory Statistics students, the professor has each student toss...
COIN TOSSES In a large class of introductory Statistics students, the professor has each student toss a coin 16 times and calculate the proportion of his or her tosses that were heads. The students then report their results, and the professor plots a histogram of these several proportions. What shape would you expect this histogram to be? Why? Where do you expect the histogram to be centred? How much variability would you expect among these proportions? Explain why a Normal...
Toss a fair coin repeatedly. Let N1 be the number of tosses required to obtain heads...
Toss a fair coin repeatedly. Let N1 be the number of tosses required to obtain heads followed immediately by tails. Let N2 be the number of tosses required to obtain two heads in a row. (A) Should N1 and N2 have the same expected value? If not, which expected value should be larger? Explain your answers. (B) Find the probability mass function of N1. (C) Find the expected value of N1. (D) Find the probability mass function of N2. (E)...
Consider the following experiment: Simultaneously toss a fair coin and, independently, roll a fair die. Write...
Consider the following experiment: Simultaneously toss a fair coin and, independently, roll a fair die. Write out the 12 outcomes that comprise the sample space for this experiment. Let X be a random variable that takes the value of 1 if the coin shows “heads” and the value of 0 if the coin shows “tails”. Let Y be a random variable that takes the value of the “up” face of the tossed die. And let Z = X + Y....
Coin toss experiment In this experiment, determine the number of heads and tails after flipping a...
Coin toss experiment In this experiment, determine the number of heads and tails after flipping a coin for 1000 times. Use two different methods to find number of heads and tails Use for loops Use vectors in MATLAB. Repeat this experiment to find running average of flipping a coin for 200 and 2000 times. Plot the running average for two experiments using subplot functions
Coin toss experiment In this experiment, determine the number of heads and tails after flipping a...
Coin toss experiment In this experiment, determine the number of heads and tails after flipping a coin for 1000 times. Use two different methods to find number of heads and tails: Use for loops. Use vectors in MATLAB. Repeat this experiment to find running average of flipping a coin for 200 and 2000 times. Plot the running average for two experiments using subplot functions.
Consider a coin toss experiment and the following assets. A gives £200 if the first is...
Consider a coin toss experiment and the following assets. A gives £200 if the first is heads, £50 for tails. B gives £200 if the second is heads and £50 for tails. C is half of A plus half of B. A and B are independent. Show that the expected value of each asset isthe same. Show that C reduces risk and explain why this is so. [Hint: You need to calculate E(A), E(B), and E(C). Also calculate the standard...
In C++  Write a program that simulates coin tossing. For each toss of the coin the program...
In C++  Write a program that simulates coin tossing. For each toss of the coin the program should print heads or tails. Let the program toss the coin 100 times and count the number times each side of the coin appears. Print the results. 0 represents tails and 1 for heads.
Premise: Every coin toss thus far has come up tails. Conclusion: The next coin toss will...
Premise: Every coin toss thus far has come up tails. Conclusion: The next coin toss will come up heads Argument A proceeds from the (general to the general) / or (general to particular) /or (particular to particular) / or (particular to general) ? According to the modern view of deduction and induction, Argument A is (inductive or deductive)? NOTE: Please provide the appropriate answer and not an uncertain response.
Analysis question The probability of landing heads in a coin toss is 1/2. Use this information...
Analysis question The probability of landing heads in a coin toss is 1/2. Use this information to explain why the remaining number of pennies is reduced by about half each time they are shaken and tossed.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT