Last chance! 50% off unlimited learning
Sale ends in
nclass.Sturges(x)
nclass.scott(x)
nclass.FD(x)
nclass.Sturges
uses Sturges' formula, implicitly basing bin
sizes on the range of the data. nclass.scott
uses Scott's choice for a normal distribution based on
the estimate of the standard error, unless that is zero where it
returns 1
. nclass.FD
uses the Freedman-Diaconis choice based on the
inter-quartile range (IQR
) unless that's zero where it
reverts to mad(x, constant = 2)
and when that is 1
.hist
and truehist
(package
https://CRAN.R-project.org/package=MASS); dpih
(package
https://CRAN.R-project.org/package=KernSmooth) for a plugin bandwidth proposed by Wand(1995).set.seed(1)
x <- stats::rnorm(1111)
nclass.Sturges(x)
## Compare them:
NC <- function(x) c(Sturges = nclass.Sturges(x),
Scott = nclass.scott(x), FD = nclass.FD(x))
NC(x)
onePt <- rep(1, 11)
NC(onePt) # no longer gives NaN
Run the code above in your browser using DataLab