You are here:

# Advanced Math/Probability(checking whether a coin is fair variation)

Question
QUESTION: I'm looking for a confirmation that I'm using the right formula and my implementation and interpretation of the results are correct, rather than answer to a specific question.

Question/Situation:
Fair coin is being manipulated by outside force.  Trying to figure out that outside force value.

Looked up: checking whether a coin is fair: http://en.wikipedia.org/wiki/Checking_if_a_coin_is_fair
Using "Estimator of true probability (Frequentist approach"

That gives me formula E = Z/{2^(1/2)}.  For example 100 tosses with 90% confidence, I get E = 1.6449/{(2^(1/2)} = .082245  Therefore .417755 < r < .582245

Now am I correct in assuming that I have 90% confidence that anything outside of that above range is due to outside manipulation, and likewise I have a 10% confidence that anything within that above range is due to outside manipulation?  Since I already know coin is already 100% fair, I'm assuming I can use the E value to help me value the manipulation force instead, rather than use it to figure out if coin is fair or not, as the formula was originally intended.  So interpreting the results in reverse.    Am I right in my interpretation and/or implementation?

First, your formula assumes p=1/2, i.e. that it is a fair coin. If you think the coin is not fair, you have to include p in your formula, but this only results in = becoming ≤ so that error is not so bad.

But you have also totally omitted "n" from the formula, which is a problem.

E = Z √( p(1-p)/n )

Now, if you want to estimate the actual value (which Wikipedia calls r) for the probability of getting heads, you have to do n trials, and compute:

p = h / n

where h is the number of heads that come up in the trials. From this, you can use Z=1.6449 if you want 90% confidence to obtain:

|p-r| < E = Z √( p(1-p)/n )  1.6449 √( p(1-p) ) / √n  ≤ 1.6449 / ( 2√n)

From this, you really have to decide how much error you are allowed to have. Let's say you want to estimate r with error ε. Then you need:

1.6449 / 2 ≤ ε √n

0.82245 ≤ ε √n

0.67642 / ε^2 ≤ n

So let's say you wanted to estimate r (the true bias of the coin), with 0.01 (which is 1%) accuracy and 90% confidence. Then you need to do:

0.67642 / 0.01^2 ≤ n

6764 ≤ n

You need 6764 trials, approximately. For example, I made a computer simulation of a coin that has a 70-30 bias for heads. Running only 100 trials gives me 74%. Doing 100 trials again gives me 60%. These are not good estimates.

However, doing 7000 trials gives 69.2%, then 68.9%, then 70.5%, which are very close.

---------- FOLLOW-UP ----------

QUESTION: Sorry about that, my formula was a mistake of poor copying/proofreading.  As you can see, my answer to the formula has n in it, I just didn't copy the formula correctly.  1.6449/{2^(1/2)}≠ .082245.  Input n = 100 in the proper location and you do get .082245.

The question/problem I am having isn't a lack of understanding of the direct use of the formula, ie. checking fairness of coin, I know how to do that and rearrange the formula to figure out any one of the unknown variables.  I'm just having trouble where else I could also apply the formula and then interpret those results accurately.

Maybe I can expand my example.  Again assume the coin is actually fair, p=.5, call it "God's coin" so we know it to be 100% fair.  But I don't know if there is an outside force that may effect the fair coin or not, in this case lets say the environment(wind/pressure/etc.) may effect the fair coin when it is flipped.  So back to my example with 90% confidence, 100 tosses.  I should get a range of .417755 < r < .582245 if I know coin is fair.  If my actual experiment results were 70 heads and 30 tails, p = .7, therefore .617755 < r < .782245.  Therefore with 90% confidence I can argue there are environmental effects, since the actual range value of r falls well out of what I would expect given a fair coin.  But how much can I reasonably assume is due to the environment?  The actual difference is p(environ) - p(fair) = .7 - .5 = .2, but I can't say that environment is for sure .2 biased.  This is kind of where I get lost, I'm trying to come up with some biased interval amount for the environment.  Could I do the following: take the interval of .617755 < r < .782245 based on the actual experiment, and subtract from it .5, which is the p value of a  fair coin.  I now get a range of .117755 to .282245.  Can I then assume with 90% confidence that the environmental bias is somewhere within that range?  Or should I subtract .582245, which is the upper range of the original formula, and subtract that from the interval .617755 < r < .782245 from actual results, for a range of .03551 to .2, then say 90% confidence that maximum bias is within that range?  Am I using the formula wrong and/or interpreting the results incorrectly?

Thanks for the help.

The formula I've given you is already correct. "The environmental factors" is really just what is "r" in my formulas. Even if your coin is "God's coin," once you introduce "other factors" that is simply a bias, whether it is inherent in the coin or comes from the environment is irrelevant -- furthermore, statistics/probability cannot tell you what the source of bias is.

Furthermore, you CANNOT measure r. That's an important paradigm of probability. Instead, you estimate it by computing p. According to your example, p=70% or 0.7 with n=100. From this you use my formula above:

|p-r| < E = Z √( p(1-p)/n )  1.6449 √( p(1-p) ) / √n  ≤ 1.6449 / ( 2√n)

|0.7-r| < 1.6449 / ( 2√100) = 1.6449 / 20 = 0.082245

From this, you get:

0.7 - 0.082245 < r < 0.7 + 0.082245

0.617755 < r < 0.782245

That is precisely what you've got, so it seems you're applying this result correctly. To get a an interval with higher confidence (e.g. 95%) you replace Z with a different Z-score. To get a smaller interval, use more coin flips (e.g. n=1000).

So yeah, I think you're on the right track.
Questioner's Rating
 Rating(1-10) Knowledgeability = 10 Clarity of Response = 10 Politeness = 10 Comment "that is simply a bias, whether it is inherent in the coin or comes from the environment is irrelevant" That is what I was kind of looking for. I figured that was the answer and just wanted confirmation from an expert, as well as confirmation that I was using the equation properly. Thanks a lot, great help.

Volunteer

#### Clyde Oliver

##### Expertise

I can answer all questions up to, and including, graduate level mathematics. I am more likely to prefer questions beyond the level of calculus. I can answer any questions, from basic elementary number theory like how to prove the first three digits of powers of 2 repeat (they do, with period 100, starting at 8), all the way to advanced mathematics like proving Egorov's theorem or finding phase transitions in random networks.

##### Experience

I am a PhD educated mathematician working in research at a major university.

Organizations
AMS

Publications
Various research journals of mathematics. Various talks & presentations (some short, some long), about either interesting classical material or about research work.

Education/Credentials
BA mathematics & physics, PhD mathematics from a top 20 US school.

Awards and Honors
Various honors related to grades, various fellowships & scholarships, awards for contributions to mathematics and education at my schools, etc.

Past/Present Clients
In the past, and as my career progresses, I have worked and continue to work as an educator and mentor to students of varying age levels, skill levels, and educational levels.