Order in a Biased Coin [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
5
down vote
favorite
Situation:
Consider the classic coin tossing experiment. We want to explore if the coin is biased.
Coin 1: Coin is tossed $50$ times. We get $20$T and then $30$H, in that sequence
Coin 2: Coin is tossed $50$ times. We get $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H in that sequence.
Q1 : Is the probability of Coin 1 and Coin 2 being biased is the same? My gut feel is that yes, because each event is independent so the order of the events doesn't matter at all.
Q2: I have a coin toss where observations are not independent. P(H | Previous toss is tail) = $0.6$ and P(T | Previous Head) = $0.5$ What kind of statistical test can I use to check the probability of coin being biased?
probability
closed as off-topic by amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel Jul 18 at 10:34
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel
 |Â
show 1 more comment
up vote
5
down vote
favorite
Situation:
Consider the classic coin tossing experiment. We want to explore if the coin is biased.
Coin 1: Coin is tossed $50$ times. We get $20$T and then $30$H, in that sequence
Coin 2: Coin is tossed $50$ times. We get $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H in that sequence.
Q1 : Is the probability of Coin 1 and Coin 2 being biased is the same? My gut feel is that yes, because each event is independent so the order of the events doesn't matter at all.
Q2: I have a coin toss where observations are not independent. P(H | Previous toss is tail) = $0.6$ and P(T | Previous Head) = $0.5$ What kind of statistical test can I use to check the probability of coin being biased?
probability
closed as off-topic by amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel Jul 18 at 10:34
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel
For 1, just compute the probability of each of the specific outcomes. For 2, what is your definition of biased considering the correlation? You have the specific probabilities. The coin does not appear biased to me because of the symmetry. In the long run, you should still get half heads, half tails. Long runs of heads and tails should be more common than with a coin where the tosses are independent.
– Ross Millikan
Jul 18 at 0:30
Thanks Ross, I have edited the Q2
– Penrose
Jul 18 at 0:51
Now you can just flip a lot of times. Compute the long term average fraction of heads and tails. It will not be $0.5$ each.
– Ross Millikan
Jul 18 at 0:53
Ross - the question is that no matter how many flips I do, the probability of coin being biased is not going to be 100%, how do ascertain that probability? Could I simply flips coins and do a t-test and estimate that?
– Penrose
Jul 18 at 1:53
Your null hypothesis is that the long term average is half heads. When the offset from half gets large enough you declare the coin biased. I think that is the t-test, but I don't remember. You could also look at TT vs TH, which is more biased.
– Ross Millikan
Jul 18 at 2:02
 |Â
show 1 more comment
up vote
5
down vote
favorite
up vote
5
down vote
favorite
Situation:
Consider the classic coin tossing experiment. We want to explore if the coin is biased.
Coin 1: Coin is tossed $50$ times. We get $20$T and then $30$H, in that sequence
Coin 2: Coin is tossed $50$ times. We get $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H in that sequence.
Q1 : Is the probability of Coin 1 and Coin 2 being biased is the same? My gut feel is that yes, because each event is independent so the order of the events doesn't matter at all.
Q2: I have a coin toss where observations are not independent. P(H | Previous toss is tail) = $0.6$ and P(T | Previous Head) = $0.5$ What kind of statistical test can I use to check the probability of coin being biased?
probability
Situation:
Consider the classic coin tossing experiment. We want to explore if the coin is biased.
Coin 1: Coin is tossed $50$ times. We get $20$T and then $30$H, in that sequence
Coin 2: Coin is tossed $50$ times. We get $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H, $4$T $6$H in that sequence.
Q1 : Is the probability of Coin 1 and Coin 2 being biased is the same? My gut feel is that yes, because each event is independent so the order of the events doesn't matter at all.
Q2: I have a coin toss where observations are not independent. P(H | Previous toss is tail) = $0.6$ and P(T | Previous Head) = $0.5$ What kind of statistical test can I use to check the probability of coin being biased?
probability
edited Jul 18 at 0:51
asked Jul 18 at 0:13


Penrose
284
284
closed as off-topic by amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel Jul 18 at 10:34
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel
closed as off-topic by amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel Jul 18 at 10:34
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "This question is missing context or other details: Please improve the question by providing additional context, which ideally includes your thoughts on the problem and any attempts you have made to solve it. This information helps others identify where you have difficulties and helps them write answers appropriate to your experience level." – amWhy, max_zorn, Gibbs, Mostafa Ayaz, Parcly Taxel
For 1, just compute the probability of each of the specific outcomes. For 2, what is your definition of biased considering the correlation? You have the specific probabilities. The coin does not appear biased to me because of the symmetry. In the long run, you should still get half heads, half tails. Long runs of heads and tails should be more common than with a coin where the tosses are independent.
– Ross Millikan
Jul 18 at 0:30
Thanks Ross, I have edited the Q2
– Penrose
Jul 18 at 0:51
Now you can just flip a lot of times. Compute the long term average fraction of heads and tails. It will not be $0.5$ each.
– Ross Millikan
Jul 18 at 0:53
Ross - the question is that no matter how many flips I do, the probability of coin being biased is not going to be 100%, how do ascertain that probability? Could I simply flips coins and do a t-test and estimate that?
– Penrose
Jul 18 at 1:53
Your null hypothesis is that the long term average is half heads. When the offset from half gets large enough you declare the coin biased. I think that is the t-test, but I don't remember. You could also look at TT vs TH, which is more biased.
– Ross Millikan
Jul 18 at 2:02
 |Â
show 1 more comment
For 1, just compute the probability of each of the specific outcomes. For 2, what is your definition of biased considering the correlation? You have the specific probabilities. The coin does not appear biased to me because of the symmetry. In the long run, you should still get half heads, half tails. Long runs of heads and tails should be more common than with a coin where the tosses are independent.
– Ross Millikan
Jul 18 at 0:30
Thanks Ross, I have edited the Q2
– Penrose
Jul 18 at 0:51
Now you can just flip a lot of times. Compute the long term average fraction of heads and tails. It will not be $0.5$ each.
– Ross Millikan
Jul 18 at 0:53
Ross - the question is that no matter how many flips I do, the probability of coin being biased is not going to be 100%, how do ascertain that probability? Could I simply flips coins and do a t-test and estimate that?
– Penrose
Jul 18 at 1:53
Your null hypothesis is that the long term average is half heads. When the offset from half gets large enough you declare the coin biased. I think that is the t-test, but I don't remember. You could also look at TT vs TH, which is more biased.
– Ross Millikan
Jul 18 at 2:02
For 1, just compute the probability of each of the specific outcomes. For 2, what is your definition of biased considering the correlation? You have the specific probabilities. The coin does not appear biased to me because of the symmetry. In the long run, you should still get half heads, half tails. Long runs of heads and tails should be more common than with a coin where the tosses are independent.
– Ross Millikan
Jul 18 at 0:30
For 1, just compute the probability of each of the specific outcomes. For 2, what is your definition of biased considering the correlation? You have the specific probabilities. The coin does not appear biased to me because of the symmetry. In the long run, you should still get half heads, half tails. Long runs of heads and tails should be more common than with a coin where the tosses are independent.
– Ross Millikan
Jul 18 at 0:30
Thanks Ross, I have edited the Q2
– Penrose
Jul 18 at 0:51
Thanks Ross, I have edited the Q2
– Penrose
Jul 18 at 0:51
Now you can just flip a lot of times. Compute the long term average fraction of heads and tails. It will not be $0.5$ each.
– Ross Millikan
Jul 18 at 0:53
Now you can just flip a lot of times. Compute the long term average fraction of heads and tails. It will not be $0.5$ each.
– Ross Millikan
Jul 18 at 0:53
Ross - the question is that no matter how many flips I do, the probability of coin being biased is not going to be 100%, how do ascertain that probability? Could I simply flips coins and do a t-test and estimate that?
– Penrose
Jul 18 at 1:53
Ross - the question is that no matter how many flips I do, the probability of coin being biased is not going to be 100%, how do ascertain that probability? Could I simply flips coins and do a t-test and estimate that?
– Penrose
Jul 18 at 1:53
Your null hypothesis is that the long term average is half heads. When the offset from half gets large enough you declare the coin biased. I think that is the t-test, but I don't remember. You could also look at TT vs TH, which is more biased.
– Ross Millikan
Jul 18 at 2:02
Your null hypothesis is that the long term average is half heads. When the offset from half gets large enough you declare the coin biased. I think that is the t-test, but I don't remember. You could also look at TT vs TH, which is more biased.
– Ross Millikan
Jul 18 at 2:02
 |Â
show 1 more comment
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
Your goal here is to test the marginal probability of a head in your coins. However, you need to be careful with your assumptions. You say in your question that the coin tosses are independent, but the data for the coins clearly falsifies this. The standard coin-toss model with independent outcomes is based on an assumption of exchangeability of the outcomes, which can be tested via a permutation test (e.g., a runs test). For a binary process with twenty observed tails and thirty observed heads, the distribution of the number of runs is shown in the plot below (R
code for this plot below).
In your data, Coin 1 has two runs and Coin 2 has ten runs. Two runs is so far in the tails that we do not get a single random generation of this in $10^6$ simulations, yielding a simulated p-value of zero. Ten runs is so far in the tails that we get a value as or more extreme than this only seven times in $10^6$ simulations, yielding a simulated p-value close to zero. In short, for both coins ( but especially the first), there is extremely strong evidence that exchangeability does not hold, so the tosses are not independent (even when we condition on the marginal probability of a head).
Given that your coin tosses show evidence of non-exchangeability, you need to base your analysis on some kind of more general model (e.g., a binary auto-regression (BAR) model). Now, you might still find that the evidence for the marginal probability of heads is the same in both cases, under a more general model. However, you cannot base this on an assumption of independence of tosses, which is clearly falsified by the observed data.
R code for this plot:
#Define a function to calculate the runs for an input vector
RUNS <- function(x) n <- length(x);
R <- 1;
for (i in 2:n) if(x[i] != x[i-1]) R <- R+1;
R
#Simulate the runs statistic for k permutations
k <- 10^6;
set.seed(12345);
RR <- rep(0, k);
for (i in 1:k) x_perm <- sample(x, length(x), replace = FALSE);
RR[i] <- RUNS(x_perm);
#Generate the frequency table for the simulated runs
FREQS <- as.data.frame(table(RR));
#Plot estimated distribution of runs
library(ggplot2);
ggplot(data = FREQS, aes(x = RR, y = Freq/k, colour = 'Red', fill = 'Red')) +
geom_bar(stat = 'identity') +
theme(legend.position = 'none') +
labs(title ='Plot of Distribution of Runs',
subtitle = '(Simulation using 1,000,000 generated values)',
x = 'Runs', y = 'Estimated Probability');
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
add a comment |Â
up vote
2
down vote
A detailed answer has already been given under the assumption that the independence of the coin tosses is in question. I interpreted the question to mean that the independence assumption stands and you merely want to consider the possibility of the coin being biased away from the uniform distribution for $p=frac12$.
In this case, the answer to Question $1$ is affirmative. In this experiment, the number of heads is a sufficient statistic for the parameter $p$ of interest, the probability of the coin to yield heads. That is, it contains all the information about this parameter that the entire run of data contains. Formally, the likelihood of the parameter conditional on the statistic is the same as the likelihood of the parameter conditional on the entire data. Thus, the order in which the results occur makes no difference in your posterior beliefs about the parameter.
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
add a comment |Â
up vote
1
down vote
Suppose I have n independent Bernoulli trials which can be simulated with the Binomial distribution. That is I have a random variable $X sim Bin(n,p)$. The pmf for this is given by $f(k,n,p) = binomnk (p)^k(1-p)^n-k $
Now...if I want to simulate say 50 coins flips..let me do that..in say Python like the following...
import numpy as np
import random
random.seed(42)
n_flips = 25
p =.50
coin_flips = np.random.choice([0,1],n_flips,[(1-p),p])
what's this look like
Out[6]:
array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
1, 1, 1])
lucky for us we know something about the mean of the binomial distribution.
$$ E(X) = np$$
So if I have a hypothesis that this is a fair coin. How can we use that to test it? If the coin is biased then we would be able to observe that the mean is different on average. So if you have 2 coins then if you subtract the two means then you would observe that the difference would be greater than you would expect. Then you compare this with a p value. It's generally called an A/B test
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
Your goal here is to test the marginal probability of a head in your coins. However, you need to be careful with your assumptions. You say in your question that the coin tosses are independent, but the data for the coins clearly falsifies this. The standard coin-toss model with independent outcomes is based on an assumption of exchangeability of the outcomes, which can be tested via a permutation test (e.g., a runs test). For a binary process with twenty observed tails and thirty observed heads, the distribution of the number of runs is shown in the plot below (R
code for this plot below).
In your data, Coin 1 has two runs and Coin 2 has ten runs. Two runs is so far in the tails that we do not get a single random generation of this in $10^6$ simulations, yielding a simulated p-value of zero. Ten runs is so far in the tails that we get a value as or more extreme than this only seven times in $10^6$ simulations, yielding a simulated p-value close to zero. In short, for both coins ( but especially the first), there is extremely strong evidence that exchangeability does not hold, so the tosses are not independent (even when we condition on the marginal probability of a head).
Given that your coin tosses show evidence of non-exchangeability, you need to base your analysis on some kind of more general model (e.g., a binary auto-regression (BAR) model). Now, you might still find that the evidence for the marginal probability of heads is the same in both cases, under a more general model. However, you cannot base this on an assumption of independence of tosses, which is clearly falsified by the observed data.
R code for this plot:
#Define a function to calculate the runs for an input vector
RUNS <- function(x) n <- length(x);
R <- 1;
for (i in 2:n) if(x[i] != x[i-1]) R <- R+1;
R
#Simulate the runs statistic for k permutations
k <- 10^6;
set.seed(12345);
RR <- rep(0, k);
for (i in 1:k) x_perm <- sample(x, length(x), replace = FALSE);
RR[i] <- RUNS(x_perm);
#Generate the frequency table for the simulated runs
FREQS <- as.data.frame(table(RR));
#Plot estimated distribution of runs
library(ggplot2);
ggplot(data = FREQS, aes(x = RR, y = Freq/k, colour = 'Red', fill = 'Red')) +
geom_bar(stat = 'identity') +
theme(legend.position = 'none') +
labs(title ='Plot of Distribution of Runs',
subtitle = '(Simulation using 1,000,000 generated values)',
x = 'Runs', y = 'Estimated Probability');
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
add a comment |Â
up vote
2
down vote
accepted
Your goal here is to test the marginal probability of a head in your coins. However, you need to be careful with your assumptions. You say in your question that the coin tosses are independent, but the data for the coins clearly falsifies this. The standard coin-toss model with independent outcomes is based on an assumption of exchangeability of the outcomes, which can be tested via a permutation test (e.g., a runs test). For a binary process with twenty observed tails and thirty observed heads, the distribution of the number of runs is shown in the plot below (R
code for this plot below).
In your data, Coin 1 has two runs and Coin 2 has ten runs. Two runs is so far in the tails that we do not get a single random generation of this in $10^6$ simulations, yielding a simulated p-value of zero. Ten runs is so far in the tails that we get a value as or more extreme than this only seven times in $10^6$ simulations, yielding a simulated p-value close to zero. In short, for both coins ( but especially the first), there is extremely strong evidence that exchangeability does not hold, so the tosses are not independent (even when we condition on the marginal probability of a head).
Given that your coin tosses show evidence of non-exchangeability, you need to base your analysis on some kind of more general model (e.g., a binary auto-regression (BAR) model). Now, you might still find that the evidence for the marginal probability of heads is the same in both cases, under a more general model. However, you cannot base this on an assumption of independence of tosses, which is clearly falsified by the observed data.
R code for this plot:
#Define a function to calculate the runs for an input vector
RUNS <- function(x) n <- length(x);
R <- 1;
for (i in 2:n) if(x[i] != x[i-1]) R <- R+1;
R
#Simulate the runs statistic for k permutations
k <- 10^6;
set.seed(12345);
RR <- rep(0, k);
for (i in 1:k) x_perm <- sample(x, length(x), replace = FALSE);
RR[i] <- RUNS(x_perm);
#Generate the frequency table for the simulated runs
FREQS <- as.data.frame(table(RR));
#Plot estimated distribution of runs
library(ggplot2);
ggplot(data = FREQS, aes(x = RR, y = Freq/k, colour = 'Red', fill = 'Red')) +
geom_bar(stat = 'identity') +
theme(legend.position = 'none') +
labs(title ='Plot of Distribution of Runs',
subtitle = '(Simulation using 1,000,000 generated values)',
x = 'Runs', y = 'Estimated Probability');
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
add a comment |Â
up vote
2
down vote
accepted
up vote
2
down vote
accepted
Your goal here is to test the marginal probability of a head in your coins. However, you need to be careful with your assumptions. You say in your question that the coin tosses are independent, but the data for the coins clearly falsifies this. The standard coin-toss model with independent outcomes is based on an assumption of exchangeability of the outcomes, which can be tested via a permutation test (e.g., a runs test). For a binary process with twenty observed tails and thirty observed heads, the distribution of the number of runs is shown in the plot below (R
code for this plot below).
In your data, Coin 1 has two runs and Coin 2 has ten runs. Two runs is so far in the tails that we do not get a single random generation of this in $10^6$ simulations, yielding a simulated p-value of zero. Ten runs is so far in the tails that we get a value as or more extreme than this only seven times in $10^6$ simulations, yielding a simulated p-value close to zero. In short, for both coins ( but especially the first), there is extremely strong evidence that exchangeability does not hold, so the tosses are not independent (even when we condition on the marginal probability of a head).
Given that your coin tosses show evidence of non-exchangeability, you need to base your analysis on some kind of more general model (e.g., a binary auto-regression (BAR) model). Now, you might still find that the evidence for the marginal probability of heads is the same in both cases, under a more general model. However, you cannot base this on an assumption of independence of tosses, which is clearly falsified by the observed data.
R code for this plot:
#Define a function to calculate the runs for an input vector
RUNS <- function(x) n <- length(x);
R <- 1;
for (i in 2:n) if(x[i] != x[i-1]) R <- R+1;
R
#Simulate the runs statistic for k permutations
k <- 10^6;
set.seed(12345);
RR <- rep(0, k);
for (i in 1:k) x_perm <- sample(x, length(x), replace = FALSE);
RR[i] <- RUNS(x_perm);
#Generate the frequency table for the simulated runs
FREQS <- as.data.frame(table(RR));
#Plot estimated distribution of runs
library(ggplot2);
ggplot(data = FREQS, aes(x = RR, y = Freq/k, colour = 'Red', fill = 'Red')) +
geom_bar(stat = 'identity') +
theme(legend.position = 'none') +
labs(title ='Plot of Distribution of Runs',
subtitle = '(Simulation using 1,000,000 generated values)',
x = 'Runs', y = 'Estimated Probability');
Your goal here is to test the marginal probability of a head in your coins. However, you need to be careful with your assumptions. You say in your question that the coin tosses are independent, but the data for the coins clearly falsifies this. The standard coin-toss model with independent outcomes is based on an assumption of exchangeability of the outcomes, which can be tested via a permutation test (e.g., a runs test). For a binary process with twenty observed tails and thirty observed heads, the distribution of the number of runs is shown in the plot below (R
code for this plot below).
In your data, Coin 1 has two runs and Coin 2 has ten runs. Two runs is so far in the tails that we do not get a single random generation of this in $10^6$ simulations, yielding a simulated p-value of zero. Ten runs is so far in the tails that we get a value as or more extreme than this only seven times in $10^6$ simulations, yielding a simulated p-value close to zero. In short, for both coins ( but especially the first), there is extremely strong evidence that exchangeability does not hold, so the tosses are not independent (even when we condition on the marginal probability of a head).
Given that your coin tosses show evidence of non-exchangeability, you need to base your analysis on some kind of more general model (e.g., a binary auto-regression (BAR) model). Now, you might still find that the evidence for the marginal probability of heads is the same in both cases, under a more general model. However, you cannot base this on an assumption of independence of tosses, which is clearly falsified by the observed data.
R code for this plot:
#Define a function to calculate the runs for an input vector
RUNS <- function(x) n <- length(x);
R <- 1;
for (i in 2:n) if(x[i] != x[i-1]) R <- R+1;
R
#Simulate the runs statistic for k permutations
k <- 10^6;
set.seed(12345);
RR <- rep(0, k);
for (i in 1:k) x_perm <- sample(x, length(x), replace = FALSE);
RR[i] <- RUNS(x_perm);
#Generate the frequency table for the simulated runs
FREQS <- as.data.frame(table(RR));
#Plot estimated distribution of runs
library(ggplot2);
ggplot(data = FREQS, aes(x = RR, y = Freq/k, colour = 'Red', fill = 'Red')) +
geom_bar(stat = 'identity') +
theme(legend.position = 'none') +
labs(title ='Plot of Distribution of Runs',
subtitle = '(Simulation using 1,000,000 generated values)',
x = 'Runs', y = 'Estimated Probability');
answered Jul 18 at 4:12
Ben
81911
81911
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
add a comment |Â
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
Ben, Thanks for this answer. Can I clarify what do you mean by Coin 1 has 2 runs and Coin 2 has 10 runs? Both have 50 tosses
– Penrose
Jul 18 at 4:27
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
For a binary sequence, the number of "runs" is defined as the number of series of the same value. So for the first coin you have an initial "run" of twenty tails, and then a second "run" of thirty heads. For the second coin, you have ten "runs" consisting of sequences of four tails, then six heads, etc.
– Ben
Jul 18 at 4:31
add a comment |Â
up vote
2
down vote
A detailed answer has already been given under the assumption that the independence of the coin tosses is in question. I interpreted the question to mean that the independence assumption stands and you merely want to consider the possibility of the coin being biased away from the uniform distribution for $p=frac12$.
In this case, the answer to Question $1$ is affirmative. In this experiment, the number of heads is a sufficient statistic for the parameter $p$ of interest, the probability of the coin to yield heads. That is, it contains all the information about this parameter that the entire run of data contains. Formally, the likelihood of the parameter conditional on the statistic is the same as the likelihood of the parameter conditional on the entire data. Thus, the order in which the results occur makes no difference in your posterior beliefs about the parameter.
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
add a comment |Â
up vote
2
down vote
A detailed answer has already been given under the assumption that the independence of the coin tosses is in question. I interpreted the question to mean that the independence assumption stands and you merely want to consider the possibility of the coin being biased away from the uniform distribution for $p=frac12$.
In this case, the answer to Question $1$ is affirmative. In this experiment, the number of heads is a sufficient statistic for the parameter $p$ of interest, the probability of the coin to yield heads. That is, it contains all the information about this parameter that the entire run of data contains. Formally, the likelihood of the parameter conditional on the statistic is the same as the likelihood of the parameter conditional on the entire data. Thus, the order in which the results occur makes no difference in your posterior beliefs about the parameter.
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
add a comment |Â
up vote
2
down vote
up vote
2
down vote
A detailed answer has already been given under the assumption that the independence of the coin tosses is in question. I interpreted the question to mean that the independence assumption stands and you merely want to consider the possibility of the coin being biased away from the uniform distribution for $p=frac12$.
In this case, the answer to Question $1$ is affirmative. In this experiment, the number of heads is a sufficient statistic for the parameter $p$ of interest, the probability of the coin to yield heads. That is, it contains all the information about this parameter that the entire run of data contains. Formally, the likelihood of the parameter conditional on the statistic is the same as the likelihood of the parameter conditional on the entire data. Thus, the order in which the results occur makes no difference in your posterior beliefs about the parameter.
A detailed answer has already been given under the assumption that the independence of the coin tosses is in question. I interpreted the question to mean that the independence assumption stands and you merely want to consider the possibility of the coin being biased away from the uniform distribution for $p=frac12$.
In this case, the answer to Question $1$ is affirmative. In this experiment, the number of heads is a sufficient statistic for the parameter $p$ of interest, the probability of the coin to yield heads. That is, it contains all the information about this parameter that the entire run of data contains. Formally, the likelihood of the parameter conditional on the statistic is the same as the likelihood of the parameter conditional on the entire data. Thus, the order in which the results occur makes no difference in your posterior beliefs about the parameter.
answered Jul 18 at 8:49
joriki
164k10180328
164k10180328
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
add a comment |Â
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
Thanks for the answer. This would also mean that the order will be important if the observations were not to be independent. What kind of statistic should one use in such case and what kind of test can be used to check for statistical significance?
– Penrose
Jul 18 at 11:38
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
@Penrose: I don't know much about that sort of thing -- but I get the impression that Ben (the author of the other answer) does.
– joriki
Jul 18 at 12:08
add a comment |Â
up vote
1
down vote
Suppose I have n independent Bernoulli trials which can be simulated with the Binomial distribution. That is I have a random variable $X sim Bin(n,p)$. The pmf for this is given by $f(k,n,p) = binomnk (p)^k(1-p)^n-k $
Now...if I want to simulate say 50 coins flips..let me do that..in say Python like the following...
import numpy as np
import random
random.seed(42)
n_flips = 25
p =.50
coin_flips = np.random.choice([0,1],n_flips,[(1-p),p])
what's this look like
Out[6]:
array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
1, 1, 1])
lucky for us we know something about the mean of the binomial distribution.
$$ E(X) = np$$
So if I have a hypothesis that this is a fair coin. How can we use that to test it? If the coin is biased then we would be able to observe that the mean is different on average. So if you have 2 coins then if you subtract the two means then you would observe that the difference would be greater than you would expect. Then you compare this with a p value. It's generally called an A/B test
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
add a comment |Â
up vote
1
down vote
Suppose I have n independent Bernoulli trials which can be simulated with the Binomial distribution. That is I have a random variable $X sim Bin(n,p)$. The pmf for this is given by $f(k,n,p) = binomnk (p)^k(1-p)^n-k $
Now...if I want to simulate say 50 coins flips..let me do that..in say Python like the following...
import numpy as np
import random
random.seed(42)
n_flips = 25
p =.50
coin_flips = np.random.choice([0,1],n_flips,[(1-p),p])
what's this look like
Out[6]:
array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
1, 1, 1])
lucky for us we know something about the mean of the binomial distribution.
$$ E(X) = np$$
So if I have a hypothesis that this is a fair coin. How can we use that to test it? If the coin is biased then we would be able to observe that the mean is different on average. So if you have 2 coins then if you subtract the two means then you would observe that the difference would be greater than you would expect. Then you compare this with a p value. It's generally called an A/B test
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
add a comment |Â
up vote
1
down vote
up vote
1
down vote
Suppose I have n independent Bernoulli trials which can be simulated with the Binomial distribution. That is I have a random variable $X sim Bin(n,p)$. The pmf for this is given by $f(k,n,p) = binomnk (p)^k(1-p)^n-k $
Now...if I want to simulate say 50 coins flips..let me do that..in say Python like the following...
import numpy as np
import random
random.seed(42)
n_flips = 25
p =.50
coin_flips = np.random.choice([0,1],n_flips,[(1-p),p])
what's this look like
Out[6]:
array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
1, 1, 1])
lucky for us we know something about the mean of the binomial distribution.
$$ E(X) = np$$
So if I have a hypothesis that this is a fair coin. How can we use that to test it? If the coin is biased then we would be able to observe that the mean is different on average. So if you have 2 coins then if you subtract the two means then you would observe that the difference would be greater than you would expect. Then you compare this with a p value. It's generally called an A/B test
Suppose I have n independent Bernoulli trials which can be simulated with the Binomial distribution. That is I have a random variable $X sim Bin(n,p)$. The pmf for this is given by $f(k,n,p) = binomnk (p)^k(1-p)^n-k $
Now...if I want to simulate say 50 coins flips..let me do that..in say Python like the following...
import numpy as np
import random
random.seed(42)
n_flips = 25
p =.50
coin_flips = np.random.choice([0,1],n_flips,[(1-p),p])
what's this look like
Out[6]:
array([0, 0, 0, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1,
1, 1, 1])
lucky for us we know something about the mean of the binomial distribution.
$$ E(X) = np$$
So if I have a hypothesis that this is a fair coin. How can we use that to test it? If the coin is biased then we would be able to observe that the mean is different on average. So if you have 2 coins then if you subtract the two means then you would observe that the difference would be greater than you would expect. Then you compare this with a p value. It's generally called an A/B test
edited Jul 18 at 3:05
answered Jul 18 at 2:34


RHowe
1,010815
1,010815
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
add a comment |Â
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
This is valid for independent observation. Would it hold when observations are not independent?
– Penrose
Jul 18 at 3:31
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
@Penrose this above-assumed independence. Bayes rules always gave me trouble. But it would be Bayes rule to do some kind of conditional test. I'd have to go through my book. Someone smarter than me could explain that one.
– RHowe
Jul 18 at 3:38
add a comment |Â
For 1, just compute the probability of each of the specific outcomes. For 2, what is your definition of biased considering the correlation? You have the specific probabilities. The coin does not appear biased to me because of the symmetry. In the long run, you should still get half heads, half tails. Long runs of heads and tails should be more common than with a coin where the tosses are independent.
– Ross Millikan
Jul 18 at 0:30
Thanks Ross, I have edited the Q2
– Penrose
Jul 18 at 0:51
Now you can just flip a lot of times. Compute the long term average fraction of heads and tails. It will not be $0.5$ each.
– Ross Millikan
Jul 18 at 0:53
Ross - the question is that no matter how many flips I do, the probability of coin being biased is not going to be 100%, how do ascertain that probability? Could I simply flips coins and do a t-test and estimate that?
– Penrose
Jul 18 at 1:53
Your null hypothesis is that the long term average is half heads. When the offset from half gets large enough you declare the coin biased. I think that is the t-test, but I don't remember. You could also look at TT vs TH, which is more biased.
– Ross Millikan
Jul 18 at 2:02