85 votes
Accepted

How can I determine which of two sequences of coin flips is real and which is fake?

This is a variant on a standard intro stats demonstration: for homework after the first class I have assigned my students the exercise of flipping a coin 100 times and recording the results, broadly ...
user avatar
  • 291k
62 votes
Accepted

Why is generating 8 random bits uniform on (0, 255)?

TL;DR: The sharp contrast between the bits and coins is that in the case of the coins, you're ignoring the order of the outcomes. HHHHTTTT is treated as the same as TTTTHHHH (both have 4 heads and 4 ...
user avatar
  • 79.6k
58 votes

Brain teaser: How to generate 7 integers with equal probability using a biased coin that has a pr(head) = p?

Flip the coin twice. If it lands HH or TT, ignore it and flip it twice again. Now, the coin has equal probability of coming up ...
user avatar
  • 651
54 votes
Accepted

Test if two binomial distributions are statistically different from each other

The solution is a simple google away: http://en.wikipedia.org/wiki/Statistical_hypothesis_testing So you would like to test the following null hypothesis against the given alternative $H_0:p_1=p_2$ ...
user avatar
  • 1,032
48 votes

Brain teaser: How to generate 7 integers with equal probability using a biased coin that has a pr(head) = p?

Assume that $p \in (0,1)$. Step 1:. Toss the coin 5 times. If the outcome is $(H, H, H, T, T)$, return $1$ and stop. $(H, H, T, T, H)$, return $2$ and stop. $(H, T, T, H, H)$, return $3$ and ...
user avatar
47 votes

How to tell the probability of failure if there were no failures?

The probability that a product will fail is surely a function of time and use. We don't have any data on use, and with only one year there are no failures (congratulations!). Thus, this aspect (...
user avatar
43 votes
Accepted

Generating correlated binomial random variables

Binomial variables are usually created by summing independent Bernoulli variables. Let's see whether we can start with a pair of correlated Bernoulli variables $(X,Y)$ and do the same thing. Suppose ...
user avatar
  • 291k
42 votes
Accepted

Logistic Regression - Error Term and its Distribution

In linear regression observations are assumed to follow a Gaussian distribution with a mean parameter conditional on the predictor values. If you subtract the mean from the observations you get the ...
user avatar
38 votes
Accepted

Negative binomial distribution vs binomial distribution

The difference is what we are interested in. Both distributions are built from independent Bernoulli trials with fixed probability of success, p. With the Binomial distribution, the random variable X ...
user avatar
  • 921
32 votes

What is quasi-binomial distribution (in the context of GLM)?

The difference between the binomial distribution and quasi-binomial can be seen in their probability density functions (pdf), which characterize these distributions. Binomial pdf: $$P(X=k)={n \...
user avatar
32 votes
Accepted

Exact two sample proportions binomial test in R (and some strange p-values)

If you are looking for an 'exact' test for two binomial proportions, I believe you are looking for Fisher's Exact Test. In R it is applied like so: ...
user avatar
  • 4,613
32 votes
Accepted

Why does the continuity correction (say, the normal approximation to the binomial distribution) work?

In fact it doesn't always "work" (in the sense of always improving the approximation of the binomial cdf by the normal at any $x$). If the binomial $p$ is 0.5 I think it always helps, except ...
user avatar
  • 261k
32 votes

How can I determine which of two sequences of coin flips is real and which is fake?

There are two very good answers as of writing this, and so let me add a needlessly complex yet interesting approach to this problem. I think one way to operationalize the human generated vs truly ...
user avatar
28 votes
Accepted

Prediction interval for binomial random variable

Ok, let's try this. I'll give two answers - the Bayesian one, which is in my opinion simple and natural, and one of the possible frequentist ones. Bayesian solution We assume a Beta prior on $p$, i,...
user avatar
  • 16k
27 votes

How to tell the probability of failure if there were no failures?

You can take a bayesian approach. denote the probability of failure by $\Theta$ and think of it as a random variable. A priori, before you see the results of the experiments, you might believe that $\...
user avatar
  • 2,376
27 votes
Accepted

Logistic Regression: Bernoulli vs. Binomial Response Variables

1) Yes. You can aggregate/de-aggregate (?) binomial data from individuals with the same covariates. This comes from the fact that the sufficient statistic for a binomial model is the total number of ...
user avatar
  • 667
27 votes
Accepted

Fitting a binomial GLMM (glmer) to a response variable that is a proportion or fraction

The binomial GLMM is probably the right answer. Especially with a small to moderate number of samples (9 and 10 in your example), the distribution of the response variable will probably be ...
user avatar
  • 35.4k
26 votes
Accepted

Is the result of an exam a binomial?

I would agree with your answer. Usually this kind of data would nowadays be modeled with some kind of Item Response Theory model. For example, if you used the Rasch model, then the binary answer $X_{...
user avatar
  • 115k
26 votes

How can I determine which of two sequences of coin flips is real and which is fake?

This is a class activity I've first read about in the book Teaching Statistics. A Bag of Tricks, 2nd ed. by Andrew Gelman and Deborah Nolan (they recommend 100 flips, though). Their reasoning to ...
user avatar
  • 26.1k
25 votes

Logistic Regression - Error Term and its Distribution

This has been covered before. A model that is constrained to have predicted values in $[0,1]$ cannot possibly have an additive error term that would make the predictions go outside $[0,1]$. Think of ...
user avatar
25 votes
Accepted

I don't understand the variance of the binomial

A random variable $X$ taking values $0$ and $1$ with probabilities $P(X=1)=p$ and $P(X=0)=1-p$ is called a Bernoulli random variable with parameter $p$. This random variable has \begin{eqnarray*} E(X)&...
user avatar
  • 2,019
23 votes

Brain teaser: How to generate 7 integers with equal probability using a biased coin that has a pr(head) = p?

Generalizing the case described by Dilip Sarwate Some of the methods described in the other answers use a scheme in which you throw a sequence of $n$ coins in a 'turn' and depending on the result you ...
user avatar
23 votes
Accepted

Mother milk of 6 Corona-positive (COVID-19) women does not contain the virus - can we make a confidence statement about this?

There is the rule of three saying if a certain event did not occur in a sample with $n$ subjects, the interval from $0$ to $3/n$ is a 95% confidence interval for the rate of occurrences in the ...
user avatar
21 votes

Logistic Regression - Error Term and its Distribution

To me the unification of logistic, linear, poisson regression etc... has always been in terms of specification of the mean and variance in the Generalized Linear Model framework. We start by ...
user avatar
21 votes
Accepted

Variance in estimating p for a binomial distribution

If $X$ is $\text{Binomial}(n, p)$ then MLE of $p$ is $\hat{p} = X/n$. A binomial variable can be thought of as the sum of $n$ Bernoulli random variables. $X = \sum_{i=1}^n Y_i$ where $Y_i\sim\text{...
user avatar
  • 8,672
21 votes

Brain teaser: How to generate 7 integers with equal probability using a biased coin that has a pr(head) = p?

Divide a box into seven equal-area regions, each labeled with an integer. Throw the coin into the box in such a way that it has equal probability of landing in each region. This is only half in jest -...
user avatar
  • 79.6k
20 votes

Non-uniform distribution of p-values when simulating binomial tests under the null hypothesis

The result that $p$ values have a uniform distribution under $H_0$ holds for continuously distributed test statistics - at least for point nulls, as you have here. As James Stanley mentions in ...
user avatar
  • 261k
20 votes

Negative binomial distribution vs binomial distribution

Negative binomial distribution, despite seemingly obvious relation to binomial, is actually better compared against the Poisson distribution. All three are discrete, btw. In practical applications, ...
user avatar
  • 56.6k
19 votes
Accepted

How can I model flips until N successes?

The distribution of the number of tails before achieving $10$ heads is Negative Binomial with parameters $10$ and $1/2$. Let $f$ be the probability function and $G$ the survival function: for each $n\...
user avatar
  • 291k
18 votes
Accepted

Why does a binomial glm give negative predictions?

Assuming that you are using the predict.glm() from the stats package. A quote from the manual, under the entry explaining the ...
user avatar
  • 1,572

Only top scored, non community-wiki answers of a minimum length are eligible