Skip to content

Commit

Permalink
Document how histogram bins are chosen by default (#829)
Browse files Browse the repository at this point in the history
Also avoid mentioning `sturges` in the docstring since it is not exported.

Co-authored-by: Alex Arslan <[email protected]>
  • Loading branch information
nalimilan and ararslan committed Jun 21, 2023
1 parent dd0a987 commit 586066d
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/hist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fit(::Type{Histogram{T}}, vs::NTuple{N,AbstractVector}, wv::AbstractWeights; clo
fit(Histogram{T}, vs, wv, histrange(vs,_nbins_tuple(vs, nbins),closed); closed=closed)

"""
fit(Histogram, data[, weight][, edges]; closed=:left, nbins)
fit(Histogram, data[, weight][, edges]; closed=:left[, nbins])
Fit a histogram to `data`.
Expand All @@ -377,8 +377,12 @@ Fit a histogram to `data`.
bin. If no weight vector is supplied, each observation has weight 1.
* `edges`: a vector (typically an `AbstractRange` object), or tuple of vectors, that gives
the edges of the bins along each dimension. If no edges are provided, these
are determined from the data.
the edges of the bins along each dimension. If no edges are provided, they are chosen
so that approximately `nbins` bins of equal width are constructed along each dimension.
!!! note
In most cases, the number of bins will be `nbins`. However, to ensure that the bins have
equal width, more or fewer than `nbins` bins may be used.
# Keyword arguments
Expand All @@ -387,6 +391,8 @@ Fit a histogram to `data`.
* `nbins`: if no `edges` argument is supplied, the approximate number of bins to use
along each dimension (can be either a single integer, or a tuple of integers).
If omitted, it is computed using Sturges's formula, i.e. `ceil(log2(length(n))) + 1`
with `n` the number of data points.
# Examples
Expand Down

0 comments on commit 586066d

Please sign in to comment.