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
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.
Comments
Leave a comment