# Binomial Distribution & t-Test

Starting with a Binomial Distribution with parameters $n=1000, p=0.5$ and measured successes of 300, I would like to test whether there is a significant difference between success and failure.

The obvious solution (using R):

n1 <- 300
n2 <- 700
p <- 0.5
binom.test(n1, n1+n2, p, alternative='two.sided')


I also want to use the similarity of the Binomial and Normal Distribution for "large" numbers of observations. A trivial solution may be this:

t.test(c(rep(0, n1), rep(1, n2)), mu=p, alternative='two.sided')


Properties of a Normal Distribution based on a Binomial Distribution can be calculated directly:

mu <- (n1+n2)*p
sig2 <- p*(1-p)*(n1+n2)


Therefore it should be possible to simply apply a one-sample t-test. After some trial-and-error I got this solution:

t <- (n2-mu)/sqrt(sig2)
p.value <- 2*abs(1-pt(abs(t), n1+n2-1))


Luckily the results are rather similar.

I do not understand why the t-test stated for example in Wikipedia, where an additional $\sqrt{n_1+n_2}$ is used, does not produce the right result:

t.wrong <- sqrt(n1+n2)*(n2-mu)/sqrt(sig2)


Why do I have to omit this part of the tests formula?

• Where on wikipedia does your t.wrong equation come from? – John Nov 7 '12 at 22:36
• en.wikipedia.org/wiki/Student%27s_t-test#One-sample_t-test The notation is a bit different, but its basically the same. – FloE Nov 7 '12 at 22:41
• You're mixing equations for the proportion, the results from your binom.test and t.test calls; and versions that estimate the number of successes. If you do the equations for proportions when you try to hand do the t-test (mu = 0.5, p-m, etc.), you should be able to figure this out. – John Nov 8 '12 at 2:29
• a*b/c == b/(c/a) --> it's really the same and does not matter. The German Wikipedia in fact uses this equivalent formula: de.wikipedia.org/wiki/… (look at the equation "T=") – FloE Nov 8 '12 at 8:22
• There's number of things wrong here, but I'll just mention one for the moment. To get a t distribution requires independence of the numerator and denominator. You don't have that, so you have no solid basis for using a t-test. On the other hand, under the null, you know $\sigma$, so you do have a basis for an asymptotic z-test. – Glen_b Dec 13 '13 at 3:00

• Well, in fact, the binomial parameter $n$ is a sample size ... for the $n$ Bernoulli trials that the binomial is the sum of. – Glen_b Dec 13 '13 at 2:55