# Testing to see if my data is uniform

1. Jun 25, 2012

### Nyasha

So l have got 16 data points and l would like to know if this data follows a uniform distribution. I have tried using the punif function in R, but l am not sure about the results l am getting. Can someone please tell me what is the best way and hopefully easiest way to see if data is uniformly distributed

2. Jun 26, 2012

### haruspex

It is never possible to say that a given set of data does or does not obey a certain distribution. You can estimate the likelihood of seeing the data you have if you assume that it is uniform, and you can make an estimate of the range of that distribution. But that doesn't tell you how likely it is to be uniform.
The only correct way is through Bayesian analysis. You have to plug in a priori beliefs of what the distribution might be, and how likely each possibility is. Then you can use the data to revise these estimates. The more data, the closer the revision gets to the "truth".
Failing that, I suggest you think up the most likely alternative to uniform (knowing what the data means) and show that the observations fit a uniform distribution better than they fit the alternative.

3. Jun 26, 2012

### chiro

Hey Nyasha.

One way to perform such a test is through a goodness of fit test.

The way this works intuitively is basically that it compares how 'close' each value of your expected distribution is from your observed and then based on that variation, checks whether under some confidence level using frequentist statistics if you can either reject or fail to reject the hypothesis under that test statistic, whether the observed distribution is the expected distribution.

The Bayesian analysis is a lot more general than this, but as a starting point, you could do this test to get an idea of the similarity and how big a confidence level is needed to fail to reject the hypothesis.

You are using R, so take a look at this:

http://ww2.coastal.edu/kingw/statistics/R-tutorials/goodness.html