When given a coin, we may wish to find out if the coin is fair (i.e. the probability of obtaining head (or tail) in a toss is 50%. One way of verifying this is to calculate the probability density function using Bayesian probability theory.
First perform a test by tossing the coin N times and carefully note down the number of heads H. So we have :
- n = N = total number of tosses
- h = H = total number of heads
- T = N − H = total number of tails
Next, let r be the actual probability of obtaining head in a single toss of the coin. This is the value which we wishes to find. Using Bayesian probability theory, we have:
The prior summarizes what we know about the distribution of r in the absence of any observation. We will assume in this case that the prior distribution of r is uniform over the interval [0, 1]. That is, f(r) = 1. That assumption should be considered provisional -- if some additional background information is found, we should modify the prior accordingly.
The probability of obtaining H heads in N toss of a coin with any value of r is given by
Putting it together we have :
Now using the identity
We obtained have the final formula for the probability density function:
Example
For example: N = 10, H = 7 ie. We toss the coin 10 times and get 7 heads
Graph of example
Graph of y = 1320x7 (1 − x)3 with x ranging from 0 to 1
This graph is the graph of the probability density function of r given that we had obtained 7 heads in 10 tosses (Note: r is the actual probability of obtaining head when tossing that coin).
So is the coin biased? One can be fairly confident that the coin is indeed biased because the probability Pr(0.45 < r < 0.55) of an unbiased coin is quite small when compared with the alternative hypothesis (a biased coin).
Shape of curve
The astute person would notice that the shape of the plotted curve is solely determined by the numerator
while the denominator
determines only the scaling of the plotted curve.
This means that you can plot the shape of the curve using just the equation
and by observing the plotted curve, you can ascertain whether the coin is bias and roughly how much bias it is.
The value of r where f(r) have the maximum value is rmax = H/N as you would have expected.
How many times should the coin be tossed
To determine the number of times, a coin should be tossed, you need two vital criteria.
- The radius Z of the confidence interval
- The maximum acceptable error (E)
- The radius of the confidence interval is denoted by Z and is the Z-value of a normal/gaussian curve.
- Z = 1.0 gives 68.27% confidence
- Z = 2.0 gives 95.45% confidence
- Z = 3.0 gives 99.73% confidence
- Z = 3.3 gives 99.90% confidence
- The maximum acceptable error is defined by
where p is estimated probability of obtaining heads.
The formula for the number of coin tosses is
- provided that
and
where
to satisfy the central limit theorem.
Examples
1. If the maximum error of 0.01 is desired, how many time should the coin be tossed?
at 68.27% confidence (Z = 1)
at 95.45% confidence (Z = 2)
at 99.90% confidence (Z = 3.3)
2. If the coin is tossed 40000 times, what is the maximum error of the estimated value of p (obtaining head)?
at 68.27% confidence (Z = 1)
at 95.45% confidence (Z = 2)
at 99.90% confidence (Z = 3.3)
Last updated: 06-03-2005 00:33:05