Answer to Question #138721 in Statistics and Probability for nati

Question #138721
IN R studio

# 2. More Coin TossesExperiment: 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 untilwe 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}```
1
Expert's answer
2020-10-19T17:52:51-0400

Solution


The number of trials before a success follows a geometric distribution. Simulating the number of tosses before the first Head is obtained where the probability of getting a head is 0.6:


```{r}
toss = function() {
  tosses_till_heads = rgeom(1, 0.6)
}
```


In an experiment with 100,000 repetitions, the distribution of the number of tosses until the first head is found as follows:


```{r}
set.seed(5678)


tosses_till_heads = replicate(100000, toss())
mean = mean(tosses_till_heads)
variance = var(tosses_till_heads)
mean
variance
```


The mean and variance of the distribution of trials before getting a head are 0.66203 and 1.0928172 respectively.


```{r}
mean_15 = mean(tosses_till_heads == 15)
mean_15
```


The probability of getting a head after 15 tosses is obtained as 0. The theoretical probability obtained from the pdf



"p * (1-p)^{n-1} = 0.6 * (1-0.4)^{14} = 0.000001"

This is consistent with the results from the simulation.


Probability of getting a head after 50 tosses is:


```{r}
mean_50 = mean(tosses_till_heads == 50)
mean_50
```


The probability is 0. Note that the probability of getting a Head after n tosses decreases as n increases. The probability decays to 0 as the number of tosses increases.



Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS