# Uniform Distribution Test

I've got a data-set which I assume is uniformly distributed. Say I've got N=20000 samples and a suspected p=0.25. This means that I would expect each option to show up roughly 5000 times.

How do I calculate the following interval [5000 - x, 5000 + x] such that I can say with a certain confidence that the data-set is probably NOT uniformly distributed since the number of times an option shows up falls outside of the interval?

EDIT ABCDBCDADBCDA, BDCAADBCDADBA, ADCDBDACDBDAD, CDBDACDBDACDA, That's some sample data. A sample is one cookie string! Now I want for each position in that cookie string determine if a character there is too rare or too common at that position. So I count, for all samples, the number of A's on positon 0, the number of B's, C's and D's. Suppose I get a count of 5 A's on position 0 and I would expect a count of roughly 50 A's then the character A is too rare at position 0. That's what I want to do for each character position.

• Can you provide us with some context for your data? At this point, I'm not really sure that the uniform distribution is the right one - but it's hard to tell what a more appropriate distribution would be. Nov 8, 2010 at 20:30
• More information is needed. To check for a uniform distribution one would ordinarily check all values, not just those near a particular value. The interval you request doesn't exist because it cannot answer questions about uniformity. It would be better to state in plain non-statistical terms what data you have obtained and what you're trying to accomplish.
– whuber
Nov 8, 2010 at 20:34
• Yes, there are four possible outcomes with equal probability (p=0.25). The data contains of authentication cokes which are examined for their randomness and/or patterns in it. I'm interested to see how often each possibility occurs and how far away this number is distanced from the calculated range (since the assumption already is that it is an uniform distribution with p=0.25).
– Vincent
Nov 8, 2010 at 21:00
• To clarify; I want to be able to answer the following 2 questions: "The character c is too rare at position i. It occurs only no times." and the other one is "The character c is too common at position i. It occurs more than no times."
– Vincent
Nov 8, 2010 at 21:08
• You speak of 4 possibilities. What are those four possibilities? What is a sample for you? (A cookie string or a character in a cookie string?) I would suggest following whuber's suggestion and re-state the question without reference to statistical issues. Some sample data would also help immensely.
– user28
Nov 8, 2010 at 21:34

If you want to estimate confidence intervals, treat the ABCD distribution as a multinomial distribution. You can estimate standard errors from the variance-covariance matrix, which has diagonal (variance) entries np[i](1-p[i]) and off-diagonal (covariance) entries -np[i]p[j].
If the distribution of letters seems independent of position, you can do further exploration using the runs test. Treat the letters as ordinal data, A < B < C < D; the runs test will check for runs that are too long (too few) or too short (too many). This type of test, and many others, are described in Knuth's Seminumerical Algorithms, where he discusses tests for random number generators.