nclass.hist: Histogram number of classes/bins

View source: R/utilities.R

nclass.histR Documentation

Histogram number of classes/bins

Description

Computes the optimal number of classes/bins for an histogram as the maximum between the Sturges and Freedman-Diaconis (FD) estimators. For small datasets the Sturges value will usually be chosen, while larger datasets will usually default to FD. Avoids the overly conservative behaviour of FD and Sturges for small and large datasets, respectively. This is the default option in numpy.histogram_bin_edges available in Python.

Usage

nclass.hist(x, ...)

Arguments

x

a vector of data values.

...

additional arguments to be passed to low level functions.

Value

The value of suggested number of classes/bins.

Author(s)

Luca Scrucca

See Also

nclass.FD, nclass.Sturges

Examples

set.seed(1)
x <- stats::rnorm(111)
nclass.hist(x)
x <- stats::rnorm(1111)
nclass.hist(x)

luca-scr/qcc documentation built on June 14, 2025, 9:55 p.m.