# Test for Bernoulli distribution

I'm thinking about the following problem. Assume that one is given a sequence of binary data $(x_i)_i\in\{0,1\}^n$ and that wants to determine whether or not this sequence has been generated by a Bernoulli-like random mechanism, such as coin tosses.

My first idea was to use classical statistical test theory, but the null hypothesis $$H_0=\{\text{data are not generated by a Bernoulli mechanism}\}$$ seems difficult to model mathematically. In particular, it includes the possibility that the data are not generated by any well-defined random mechanism. I have a feeling that any probabilistic reasoning breaks down, if one is not willing to make the assumption of an underlying distribution from which the observed data are sampled.

My second idea was not to try and refute the (ill-defined) null-hypothesis that the data are not Bernoulli, but rather to extract from the data as much evidence as possible to show that it is consistent with the hypothesis that the data are generated by a Bernoulli-like mechanism. One example would be to subdivide (maybe randomly) the observed data into (maybe disjoint) subsets, count the number of 1's in each subset, and compare the empirical distribution of the number of 1's to a binomial distribution. This raises the question, how the subdivisions should be done, if the order of the data matters, and if the whole approach makes any sense. It seems to contradict the fact that the number of 1's is a sufficient test statistics for a repeated Bernoulli experiment.

My question is thus the following:

What methods can one use to establish that a sequence of binary data has been generated by a Bernoulli-like random mechanism? Alternatively, how can one refute the possibility that the data have been generated by some unspecified non-Bernoulli-like random mechanism or that they have not been generated by a well-defined random mechanism at all?

I'm aware that this is not a very concrete question. Any input is appreciated.

• The number of $1$s is a sufficient statistic for a repeated Bernoulli experiment given that you already know it's a repeated Bernoulli experiment and only the parameter is unknown. That doesn't contradict the fact that the positions of the $1$s contain information about whether it's a repeated Bernoulli experiment. – joriki Mar 25 '13 at 15:08

## 2 Answers

The Bernoulli distribution is any probability distribution supported on the set $\{0,1\}$. That means there is some number $p\in[0,1]$ such that the probability assigned to the set $\{1\}$ is $p$ and that assigned to $\{0\}$ is $1-p$.

One may speak of independent Bernoulli trials or of dependent Bernoulli trials.

Here I'm going to guess that by a "Bernoulli-like process" you mean they are stochastically independent.

Independence could be a null hypothesis. Lack of independence is not a sensible null hypothesis. I think sort of test you'd use would have to depend on what sort of alternative hypothesis you have in mind. There's probably no reasonable test unless the alternative relates the dependence to some sort of structure on the index set, such as that they come in a particular order, as when integers are used as indices. Otherwise, all you've got is a certain number of $0$s and a certain number of $1$s, and that's not improbable in a Bernoulli process with some value of $p$.

You might try something like testing the independence of events. If you are looking at something Bernoulli then data points must be independent. You might just check to see if $P(A \cap B) = P(A)P(B)$ fails for two data points in which case you are not Bernoulli.

• What does $P(A\cap B)=P(A)P(B)$ mean in this context? What are the events $A$ and $B$? – joriki Mar 25 '13 at 15:12
• What would examples of events $A$ and $B$ be? And how would you approximate the probabilities of $A,B,A\cap B$ from the observed data? – Eckhard Mar 25 '13 at 15:13