Statistics/Displaying Data/Histograms

Histograms
It is often useful to look at the distribution of the data, or the frequency with which certain values fall between pre-set bins of specified sizes. The selection of these bins is up to you, but remember that they should be selected in order to illuminate your data, not obfuscate it.

A histogram is similar to a bar chart. However histograms are used for continuous (as opposed to discrete or qualitative) data. The defining property of a histogram is:
 * The area of each bar is proportional to the frequency.

If each bin has an equal width, then this can be easily done by plotting frequency on the vertical axis. However histograms can also be drawn with unequal bin sizes, for which one can plot frequency density. To produce a histogram with equal bin sizes:


 * Select a minimum, a maximum, and a bin size. All three of these are up to you. In the histogram data used above the minimum is 1, the maximum is 110, and the bin size is 10.
 * Calculate your bins and how many values fall into each of them. For the histogram data the bins are:
 * 1 &le; x < 10, 16 values.
 * 10 &le; x < 20, 4 values.
 * 20 &le; x < 30, 4 values.
 * 30 &le; x < 40, 2 values.
 * 40 &le; x < 50, 2 values.
 * 50 &le; x < 60, 1 values.
 * 60 &le; x < 70, 0 values.
 * 70 &le; x < 80, 0 values.
 * 80 &le; x < 90, 0 values.
 * 90 &le; x < 100, 0 value.
 * 100 &le; x < 110, 0 value.
 * 110 &le; x < 120, 1 value.
 * Plot the counts you figured out above. Do this using a standard bar plot.

Worked Problem
Let's say you are an avid roleplayer who loves to play Mechwarrior, a d6 (6 sided die) based game. You have just purchased a new 6 sided die and would like to see whether it is biased (in combination with you when you roll it).

What We Expect
So before we look at what we get from rolling the die, let's look at what we would expect. First, if a die is unbiased it means that the odds of rolling a six are exactly the same as the odds of rolling a 1--there wouldn't be any favoritism towards certain values. Using the standard equation for the arithmetic mean find that &mu; = 3.5. We would also expect the histogram to be roughly even all of the way across--though it will almost never be perfect simply because we are dealing with an element of random chance.

What We Get
Here are the numbers that you collect:

Analysis

 * $$\bar{X} = 3.71$$

Referring back to what we would expect for an unbiased die, this is pretty close to what we would expect. So let's create a histogram to see if there is any significant difference in the distribution.

The only logical way to divide up dice rolls into bins is by what's showing on the die face:

If we are good at visualizing information, we can simple use a table, such as in the one above, to see what might be happening. Often, however, it is useful to have a visual representation. As the amount of variety of data we want to display increases, the need for graphs instead of a simple table increases.



Looking at the above figure, we clearly see that sides 1, 3, and 6 are almost exactly what we would expect by chance. Sides 4 and 5 are slightly greater, but not too much so, and side 2 is a lot less. This could be the result of chance, or it could represent an actual anomaly in the data and it is something to take note of keep in mind. We'll address this issue again in later chapters.

Frequency Density
Another way of drawing a histogram is to work out the Frequency Density.


 * Frequency Density: The Frequency Density is the frequency divided by the class width.

The advantage of using frequency density in a histogram is that doesn't matter if there isn't an obvious standard width to use. For all the groups, you would work out the frequency divided by the class width for all of the groups.

External Links
 * Interactive Java-based Bar-Chart Applet

Return to Statistics.