Use the web app Random numbers to illustrate the long run definition of probability by stimulating short term and long term results of flipping a balanced coin. keep the probability of a head at the default value of 50% and set the number of flips to generate a stimulation to 10
Consider a fair coin so that
The R code for simulating the tosses of a coin up to 100000 times and finding the probability of occurrence of heads is given below.
m <- 100
p <- 0.5
H <- 0
for ( i in 1:m)
{
h <- rbinom(1, 1, prob=p)
if (h == 0)
{ H <- H +1}
}
pH <- H/m
pH
The output for 100 simulation (short tem result) is
> pH
[1] 0.51
The output for 100000 simulation is (long term result)
> pH
[1] 0.5022
So we can see that the probability approaches the theoretical value as the number of simulations increases.
If you have any doubt please revert.
Get Answers For Free
Most questions answered within 1 hours.