# Binomial test for a binary variable

I have a binary variable (which takes values 0,1). I have about 100k records of it. How do I determine if it follows the binomial distribution?

(I'm bascially trying to test for normality. And, if the data is not normal, I might have to apply a transformation to get the variable into a binomial distribution.)

Hey, thank you folks for clearing this up.

This was an effort as a prelude to cluster analysis. I also understand that normality of variables is more a nice to have feature for cluster analysis and that the distance measures would be valid even otherwise. Your views?

You cannot determine this through a statistical test, for a trivial reason and a profound reason.

The trivial reason is that your data consist of $k$ ones and $n-k$ zeros with $n$ about 100k. These data conform extremely closely to a Bernoulli($k/n$) distribution. No testing is necessary.

The profound reason is that you are implicitly assuming the data are independently random--but they might not be. If, for instance, they are collected by sampling a process over time, then you might be seeing long strings of $0$ followed by long strings of $1$. Modeling these as draws from a Bernoulli distribution would likely be a poor choice. Another possibility is that the values are independent but the probability of a $1$ is varying over time. (This would be an "overdispersed" Binomial model.)

No transformation of $0, 1$ will produce a normal distribution! Perhaps what you are hoping is that some statistic, such as the sample mean, is normally distributed. The Central Limit Theorem guarantees that, provided the values are independent and that the probabilities are not tending over time to either $0$ or $1$.

• (+1) The second point is very interesting.
– chl
Oct 12 '10 at 13:38
• @chl: Yes, it occurred to me as I was writing about the CLT that there could be problems with the variances converging to zero, for then the Lindeberg condition could be violated. It's easy to see why the resulting limit distribution might be non-normal, for if (for example) the chance of observing a 1 approaches zero sufficiently rapidly, then the distribution of the mean might remain strongly skewed and never get close to normal.
– whuber
Oct 12 '10 at 16:00

I completely agree with @whuber -- just wanted to add:

If you were to try to transform the data. How would you go about doing so? You would map 0 to some number say, -5 and 1 to some other number?, say 5?

0 0 0 1 0 1 1 0 1 0 1


You have:

-5 -5 -5 5 -5 5 5 -5 5 -5 5


This cannot possible be normally distributed because you still only have two values!

Each of these entries could however be Binomial(1,p) just as @whuber described [the same as Bernoulli(p) ], but not Binomial(N,p) because N is never greater than 1 if you only have binary data.

ALL binary variables have the binomial distribution, provided that the probability of success (probability to observe 1) does not change and that all their instances are independent. A rule of thumb says that binomial distribution can be fairly approximated by normal distribution when n*p>30, with n=number of instances, p=probability of success.

So, I argue that your question is about testing for independence and constant success rate. For the former, you can use Bradley run test http://www.itl.nist.gov/div898/handbook/eda/section3/eda35d.htm (I suppose it is also known by another name). For the latter, I have only a rough answer: you can split your sample in k subgroups and then build a test using the k proportions of success in the subgroups.