Bandwidth of Histogram (Lisp programs)--Alex Yu


Bandwidth of Histogram


Chong  Ho Yu, Ph.D., D. Phil.


This program is for illustrating that the appearance of a histogram is a function of bandwidth/number of bin i.e. the appearance of the distribution (the top panel) changes when the number of bins (the lower left panel) change.

After you load the program, it would prompt you to enter some values, which would be used for drawing the histogram later. You can enter a new dataset or add more observations by using the pull down menu.


The following two histograms illustrate the same dataset. The first histogram uses 9 bins whereas the second one uses 10. Even though the number of bin increases by one only, the two graphs looks very different.

Note: There are formulas to compute the proper bandwidth and number of bins:
  • n = 2^(N-1), where n = Sample size and N = Number of Bins
  • w = 2 * IQR / n^(1/3), where w = bandwidth
  • w = (maximum value - minimum value)/(1+3.332log (n), where w = bamdwidth and n = sample size


Return to front page