# Best statistic to compare frequencies in two datasets

I am looking for a statistical test to compare frequencies in a particular dataset. In a long string, a particular sequence of characters occurs at a frequency of x per 1000 characters. In some portions of the string, the frequency is higher at y per 1000 characters. Can we tell if y and x are significantly different or not?

• Did you select x and y before looking at the dataset or in response to what you're seeing in the data (such as focusing on the highest or lowest frequencies, for instance)? Is this the only such comparison you're making for this dataset, or will you be looking at other sequences as well?
– whuber
Aug 10 '11 at 19:05
• It is in response to what I am seeing in the data. For the moment this is the only such comparison I am making, though I may look at other sequences in the future. Aug 10 '11 at 19:18
• OK, then it's important to disclose the criteria you have used to identify this sequence. For instance, did it stand out among other sequences as having more variation in its frequency within the string? It will also help to say something about how the string is generated, because serial correlation among the characters can account for such variation.
– whuber
Aug 10 '11 at 19:21
• Ok. The string is a genomic sequence (can be assumed to be random for this purpose). The sequences are known binding sites for certain proteins. The portions where the frequencies are higher were identified by an experiment. I am trying to see if a certain binding site (sequence) occurs more frequently in the portions identified by the experiment as compared to the rest of the genome. Aug 10 '11 at 19:46

In a region of $N$ base pairs, you have $2(N-(L-1))$ possible positions for $L$ base pair binding sites ($L-1$ is the number of overhanging positions past the left, $N-(L-1)$ is the number of leftmost positions, and there are 2 strands). $k$ of them are real binding sites. If the underlying probability of a position being a binding site is $q$, then $k$ followed a binomial distribution with parameter $q$ and number of trials $2(N-(L-1))$
If what you want is a $p$-value, then you would take the parameter $q$ you calculated from the genome outside of the regions you found, and calculate the probability of a binomial distribution with that $q$ producing at least as many binding sites as you see.