Agent Smith said:
I want to test if a coin is biased/not.
H = The coin is biased
I think there might be a bit of confusion on what probabilities are what. It is a little confusing because there are two kinds of probabilities in this problem.
One probability is the probability that the coin shows heads. This is the usual frequentist probability, so we could call it the coin frequency. In principle, this is a property of the coin itself, based on its physical characteristics and the physical way that it is flipped.
The other probability is what we use to represent our uncertainty about the frequency. This is a Bayesian probability. In is not a property of the coin, but a property of us, based on our uncertainty and our limited knowledge about the coin.
To avoid confusion, from here on I will use "frequency" to refer to the probability of the coin landing heads and "uncertainty" to refer to the probability that represents our limited knowledge. Please be aware that both are completely valid probabilities, but they are different things.
In the excel spreadsheet I sent, ##H## is the frequency, and ##P(H)## is the uncertainty. ##P(H)## is a probability distribution of our uncertainty over all possible frequencies. So it does not just have a single value, it as a value for every possible value of ##H##.
The statement "the coin is biased" means that ##H## is not in the ROPE. So "the probability that the coin is biased" is ##P(\neg (H \ \in \ ROPE))=1-P(H \ \in \ ROPE)##.
Agent Smith said:
D = The data/evidence (70 heads in 100 flips)
P(H) = 0.5 (prior probability)
So here, ##P(H)## is a probability distribution of our uncertainty at every possible frequency. It is not a single value, but rather it is a function of ##H##. This means, to describe something where we have a 50% probability that the coin is biased means that we want to use a function ##P(H)## such that the sum of all ##P(H \ \in \ ROPE)=0.5##.
I have updated the spreadsheet and placed such a function as an example in column B. Of course, you may not like that the function has a dramatic step going from in the ROPE to out of it, but that is why I like the beta distribution for this purpose.
Agent Smith said:
##P(H|D) = \frac{P(H) \times P(D|H)}{P(D)}##
For a head-biased coin, P(heads) = 0.7
mean = 0.7
standard deviation = ##\sigma_H = \sqrt {\frac{0.7 \times 0.3}{100}} = 0.0458##
##z = \frac{0.7 - 0.7}{0.0458} = 0##
P-value = 0.5 (for outcomes as/more extreme that 0.7 proportion of heads)
##P(D|\text{coin is head-biased}) = 0.5##
For tail-biased coin, P(heads) = 0.3 or P(tails) = 0.7
mean = 0.3
standard deviation ##\sigma_T = 0.0458## (the same formula, the same inputs, the same result)
##z = \frac{0.7 - 0.3}{0.0458} = 8.73##
P-value = 0 (for outcomes as/more extreme than 0.7 proportion of heads)
For fair coin, P(heads) = 0.5
mean = 0.5
standard deviation = 0.05
##z = \frac{0.7 - 0.5}{0.05} = 4##
P-value = 0.0000633721 (for outcomes as/more extreme than 0.7 proportion of heads)
##P(D|\text{coin is unbiased/fair}) = 0.0000633721##
------------------------------
##P(D|\text{coin is biased}) = P(D|\text{coin is head-biased}) + P(D|\text{coin is tail-biased})##
##P(D|\text{coin is biased}) = 0.5 + 0 = 0.5##
------------------------------
##P(D) = P(\text{coin is biased}) \times P(D|\text{coin is biased}) + P(\text{coin is unbiased/fair}) \times P(D|\text{coin is unbiased/fair})##
##P(D) = 0.5 \times 0.5 + 0.5 \times 0.0000633721 = 0.25003168605##
----
##P(H|D) = \frac{P(H) \times P(D|H)}{P(D)} = \frac{0.5 \times 0.5}{0.25003168605} = 0.99987##
Correct?
You essentially used Baye's theorem once, based on treating ##P(H)## as a single value. What you want to do is evaluate Baye's theorem for every possible frequency. So you use it once for each value of ##H##. That is what is calculated in column F in the spreadsheet.
Notice that with 70 heads and 30 tails, even though we started with a prior uncertainty that the coin was 50% likely to be fair, in the end the data has convinced us that there is only a 1.3% chance that the coin is fair. The data has dramatically changed our uncertainty about the fairness of the coin.