Your American History Reference Guide!
- Checking if a coin is biased

HistoryMania Information Site on Checking if a coin is biased American History American History Search        American History Browse welcome to our free resource site for all enthusiasts!

Checking if a coin is biased

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 = NH = 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:

f(r | n=N, h=H) =    \frac {P(h=H | r, n=N) \, f(r)} {\int_0^1 P(h=H|r, n=N) \, f(r) \, dr}

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.

f(r) = 1 \,\!

The probability of obtaining H heads in N toss of a coin with any value of r is given by

P( h=H | r, n=N) = {N \choose H} \, r^H \, (1-r)^T

Putting it together we have :

f(r | n=N, h=H) =   \frac {{N \choose H} \, r^H \, (1-r)^T } {\int_0^1 {N \choose H} \, r^H \, (1-r)^T \, dr}  = \frac { r^H \, (1-r)^T } {\int_0^1 r^H \, (1-r)^T \, dr}

Now using the identity

{\int_0^1 x^A \, (1-x)^B \, dx} = \sum_{k=0}^B {(-1)^k \, \frac {{B \choose k}}{A+1+k}}

We obtained have the final formula for the probability density function:

f(r | n=N, h=H) =   \frac { r^H \, (1-r)^T } {\sum_{k=0}^T {(-1)^k \, \frac {{T \choose k}}{H+1+k}}}
Contents

Example

For example: N = 10, H = 7 ie. We toss the coin 10 times and get 7 heads

f(r | n=10, h=7) = \frac { r^7 \, (1-r)^3 } {\sum_{k=0}^3 {(-1)^k \, \frac {{3 \choose k}}{7+1+k}}} = 1320 \, r^7 \, (1-r)^3

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

r^H \, (1-r)^T

while the denominator

\, \sum_{k=0}^T {(-1)^k \, \frac {{T \choose k}}{H+1+k}}

determines only the scaling of the plotted curve.

This means that you can plot the shape of the curve using just the equation r^H \, (1-r)^T 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.

  1. The radius Z of the confidence interval
  2. 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 \left | p - p_\mathrm{actual} \right | < E where p is estimated probability of obtaining heads.

The formula for the number of coin tosses is

E = \frac {Z}{ \sqrt{n} }
provided that np \ge 5 and nq \ge 5 where q = 1-p\, 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?

E = Z/ \sqrt{n}
n = \frac {Z^2} {E^2} = \frac {Z^2} {0.01^2} = 10000 \ Z^2
n = 10000\, at 68.27% confidence (Z = 1)
n = 40000\, at 95.45% confidence (Z = 2)
n = 108900\, 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)?

E = \frac {Z}{ \sqrt{n} }
E = \frac {Z}{ \sqrt{ 40000 } } = \frac {Z}{ 200 }
E = 0.005\, at 68.27% confidence (Z = 1)
E = 0.01\, at 95.45% confidence (Z = 2)
E = 0.0165\, at 99.90% confidence (Z = 3.3)
Last updated: 06-03-2005 00:33:05
The contents of this article are licensed from Wikipedia.org under the
GNU Free Documentation License. How to see transparent copy
Search | Browse | Contact | Legal info