Sie sind auf Seite 1von 7

Baised coin detection Algorithm

by Shubham Choudhary (Computer Science and Engineering, Indian Institute of Technology Ropar , Oct 2012)
Entry no 2010CS1011

ABSTRACT

This paper is all about how to detect whether a coin is fair or not and how many trials it
needs to convey this with maximum confidence level. Coin tossing is a simple and unbiased way of settling a dispute or deciding between two or more arbitrary options. It is used widely in sports and other games to decide arbitrary factors such as which side will take the decision of attacking or defending initially. In some jurisdictions, a coin is tossed to decide between two candidates who secured equal number of votes in the election or between two companies tendering for a project with equal price. But how can we say whether the coin is fair. A coin can be partially biased towards a part or can be totally biased also. So here we come up with a methd to find the biased value of the coin.

1. INTRODUCTION
A simple method to find the biased value of a coin is to toss it a number of time and note the number of heads and tails and then conclude the biased value of the coin. But how many times should we toss the coin, is the whole question? So here we come up with an algorithm to find the number of trials required to find the biased value of a coin.

2.METHOD
This detection method can be split into two parts. First finding the expected value of the biased value of the coin with the help of proterious probability density function when number of heads occured are given and second is to find the number of trials required to find the biased value of the coin with a specific tolerable margin of error.

2.1 Prosterious Probability Density Function


Firstly we come up with a method to find the biased value of a coin if we are provided with the number of the trials and the number of heads occured. We will do this by calculating the posterior probability density function of Bayesian probability theory. The Bayesian probability can be seen as a logic that enables reasoning with propositions whose correctness is uncertain. The Bayesian probability specifies some prior probabilities which is updated then by the new and relevant information. The posterior probability of a random event is the conditional probability that is assigned after the relevant evidences are taken into consideration. Similarly a posterior probability distribution is a distribution of an unknown quantity which is treated as a random variable conditioned on the evidences obtained from an experiment or survey.

Here we perform a test by tossing the coin, who's biased value is unknown, for N times and noting the observed numbers of heads and tails as h and t respectively. The symbols H and T represents more generalised variable expressing the numbers of heads h and tails t respectively that might have been observed in the experiment. Thus we have N = H + T = h + t. Let be the actual probability of obtaining heads in a single toss of the coin. We are investigating this property only of a coin. By Baye's theorem we have probability of an event W conditioned on event L as

Hence by using Baye's theorem, the posterior probability t is expressed as follows:

density of conditional on h and

where g(r) represents the prior probability density distribution of

, which lies in the range 0 to 1.

Since is a contineous random variable hence its probability density is considered. We can derive the above density formula as follows.

And

because if total N trials are there and h heads and t tails then N = h + t. By using the Law Of Total Probability

but since the value of

varies from 0 to 1 we have

We will assume that the prior distribution of [0, 1], hence g(r)= 1/(1-0) = 1 .

as uniform distribution over the interval

The probability of binomial distribution of obtaining h heads in N tosses of a coin with a probability of heads equal to r is

substituting the above probability in the previous formula we get

The Beta function is a special function defined as

Using this beta function in the above formula we get

And by the definition of gamma function we have a relation between beta and gamma function

and

Hence with the help of the aboe two relations we get our formula for prosterior probability density as

This formula gives us the probability density tosses.

function of given that h heads were obtained in N

We are able to calculate the probability of occurance of head between a particular range by integrating the above function between the particular range of limit.

Example:-

We now find the expected value of r under the posterior distribution by

This expected value will only give us the biased value of the coin and show us whether our coin is baised or unbiased.

2.2 Estimation Of Number Of Trials Required


Secondly, we now determine the number of times, a coin should be tossed to get the required expected value of , for which two vital pieces of information are required: 1. The confidence interval (Z) 2. The maximum acceptable error (E) A confidence interval is a type of interval estimate of a population paramater and is used to indicate the reliability of an estimate. It is an observed interval (i.e. it is calculated from the observations) and is different for different samples, that includes frequently the parameter of interest if the experiment is repeated many number of times. Confidence level determines how frequently the observed interval contains the parameter. The confidence level is represented by a percentage,so when 69% confidence level is there it means that 69% of the confidence interval will hold the true value of the variable. The confidence level is denoted by Z and given by the Z-value of a Standard Normal distribution. This value can be seen from the standard statistics table. Z = 1 give 68.27% confidence level Z = 2 give 95.45% confidence level Z = 3 give 99.73% confidence level

The maximum error E can be defined as

Where p is the best quantity which can estimate the value of

In statistics, the estimate of a proportion of sample (here p) has a standard error given by:

where N is the number of trials This a coin which following: standard error function of p has a maximum at p = (p-1) = 0.5. Further in case of is being tossed p will be close to 0.5, so it is appropriate to take p = 0.5 in the

Hence the value of maximum error E can be given as

Solving the above for the number of coin tosses N,

3. ANALYSIS
Now we are in a position to determine the number of trials needed to find out the biasness of a coin. Suppose we are given a coin whose biasness is not known and the maximum acceptable error (E) given is 0.01, we now have to tell the number of trials required to find the biasness of the coin and the bias value also. So we start by finding the value of N

So now if we take the confidence interval Z as 1 i.e. with confidence level 68.27% then we get trials. And if Z=3.3 i.e. With 99.90% confidence level then we get trials. We see that as we increase the confidence level there is an increase in the number of trials. Taking trials we will toss the coin for so many times and note the number of heads and tails. And with the help of

formula we will calculate the biasing the of the coin. And if the value of (0.5 + E) then we will conclude that the coin is fair.

in between (0.5 - E) to

4. ACKNOWLEDGEMENT
I would like to thanks Dr. Sudarshan Iyengar our Algorithm and Design Course Instructor for assigning us such an interesting topic related to probability which taught me some very interesting aspects of probability. Thank you.

5. REFERENCES
1. 2. 3. 4. 5. 6. 7. 8. http://en.wikipedia.org/wiki/Checking_whether_a_coin_is_fair http://en.wikipedia.org/wiki/Posterior_distribution http://en.wikipedia.org/wiki/Bayesian_probability_theory http://en.wikipedia.org/wiki/Bayes%27_theorem http://en.wikipedia.org/wiki/Beta_distribution http://en.wikipedia.org/wiki/Probability_density_function http://en.wikipedia.org/wiki/Normal_distribution http://en.wikipedia.org/wiki/Confidence_interval

Note:- Discussed with Puneet Agarwal

Das könnte Ihnen auch gefallen