Simulate a long sequence of coin tosses, encoding ‘heads’ as 1 and ‘tails’ as 0. Select weights to model a biased coin, e.g with a preference towards heads.
Calculate the relative frequency of heads to see if it is approaching the prescribed probability.
Create a dynamical plot of the relative frequency as a function of the number of tosses.
Evaluate the margin of error (MOE) to characterise the deviations.
Plot the graph of MOE as a function of the number of tosses and compare with the actual errors.