[R] Histograms and Sturges rule

Paul Smith phhs80 at gmail.com
Wed Nov 28 01:08:58 CET 2007


Dear All,

According to the Sturges rule, the number of classes of a histogram is
the closest integer to

1 + logb(n,base=2)

where n is the number of observations. The function hist(), by
default, uses the Sturges rule. However, the code

x <- 1:200
hist(x)

produces a histogram with 10 classes and not 9 classes as determined
by the Sturges rule. What am I missing?

Thanks in advance,

Paul



More information about the R-help mailing list