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.

  • $\begingroup$ 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. $\endgroup$ Nov 8, 2010 at 20:30
  • 1
    $\begingroup$ 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. $\endgroup$
    – whuber
    Nov 8, 2010 at 20:34
  • $\begingroup$ 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). $\endgroup$
    – Vincent
    Nov 8, 2010 at 21:00
  • $\begingroup$ 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." $\endgroup$
    – Vincent
    Nov 8, 2010 at 21:08
  • $\begingroup$ 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. $\endgroup$
    – user28
    Nov 8, 2010 at 21:34

1 Answer 1


You might try assuming--as your null hypothesis--that the distribution is discrete uniform independent of string position. Then tabulate the frequencies of each letter by position in a 4 x 13 contingency table. You can then test for non-independence with a simple chi-square test; with n=20,000 observations in your one sample, you shouldn't have any sparse table problems. You can also eyeball this with a stacked bar chart, one 4-color ABCD bar for each string position. This is useful if you reject the null with the chi-square test.

Just to be sure, you might also want to check your data overall to see if it actually fits a discrete uniform distribution using a chi-square goodness of fit test. After all, the distribution of characters could be independent of position without being uniformly distributed.

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].

A good reference for all this is Agresti's Categorical Data Analysis.

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.

Looks like you have a lot of tabulating to do--enjoy!


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy