Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a set of data points that I an trying to approximate with a few different probability distributions such as the gaussian or student t distributions to see which fits best.

The first step to doing this is plotting the distribution of points themselves. As per my last question, I centered the points around zero and normalized the variance = 1. Now I would like to plot these points to compare to continuous distributions. How does one do this?

I am currently using a histogram method in which I split up the points into $x$ buckets and plot the height of each bucket. Now I realize this doesn't make sense because the resulting distribution of points in the histogram is entirely dependent on the value I choose for $x$.

What is the proper way of doing this? There must be a fundamental concept I'm missing.

share|cite|improve this question
up vote 4 down vote accepted

It sounds to me like your primary difficulty is in binning the data properly. Please pardon me if this is not your question.

You want the total area of the rectangles comprising the histogram to be 1. If you take rectangle height to be the number of data points in the corresponding bin, then the total area will not be 1. Instead, you will have $$ \text{area}=(\text{bin width})\times(\text{total number of data points)}. $$ The general principle for handling distributions of binned data properly - which even allows you to deal with variable-width bins - is that rectangle area, rather than rectangle height, should be proportional to the number of data points in the bin. For the fixed-width case, the height of each rectangle should be computed as $$ \text{height}= \frac{(\text{number of data points in bin})}{(\text{total number of data points})\times(\text{width of bin})}. $$

If you follow this procedure, then, within reason, the resulting distribution should be relatively insensitive to the number of bins you decide to use. Of course, if you use too many bins, most bins will be empty and you'll get a very spiky distribution, which won't be very illuminating. If you use too few bins, the distribution will be too coarse-grained. The Wikipedia page on histograms describes some commonly used rules, such as Sturges' formula, for deciding how many bins to use.

For testing goodness of fit, you should follow the suggestions in Michael Chernick's answer.

share|cite|improve this answer

Problems like this have been discussed many times. There are numerous goodness of fit tests to use. When you bin the data the chi square test is the test to use. The idea is that you have a distribution that should have frequencies close to those observed from the data. The hypothesized distribution should exhibit close agreement with the data in terms of the bin frequencies. The test decides this by computing for each bin the squared difference of the observed with the expected dividing it by the expected and summing over all the bins. When the distribution hypotheses is the distribution sampled the test statistic has an approximate chi square distrbution.

share|cite|improve this answer

If all you need is an estimate, there are numerous ways to go about it. One such way would be to produce a Q-Q plot of the data vs. the expected distributions (normal, t, etc.). If you are wondering if the data is a normal, you could run Shapiro-Wilk test as well.

Both of these methods are very easy to implement in R or SAS (R is free with open-source code that is easy to find at

share|cite|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.