bins.greedy {binr} | R Documentation |
Greedy binning algorithm.
Description
bins.greedy
- Wrapper around bins.greedy.impl
. Goes over the
sorted values of x
left to right and fills the bins with the values until
they are about the right size.
bins.greedy.impl
- Implementation of a single-pass binning algorithm that examines sorted data left to right
and builds bins of the target size. The bins.greedy
wrapper around this function provides a less involved interface.
This is not symmetric wrt direction: symmetric distributions may not have symmetric bins if there are multiple points
with the same values. If a single value accounts for more than thresh * binsz points, it will be placed in
a new bin.
Usage
bins.greedy(x, nbins, minpts = floor(0.5 * length(x)/nbins), thresh = 0.8,
naive = FALSE)
bins.greedy.impl(xval, xtbl, xstp, binsz, nbins, thresh, verbose = F)
Arguments
x |
Vector of numbers. |
nbins |
Target number of bins. |
minpts |
Minimum number of points in a bin. Only used if |
thresh |
Threshold fraction of bin size for the greedy algorithm.
Suppose there's |
naive |
When |
xval |
Sorted unique values of the data set x. This should be the numeric version of |
xtbl |
Result of a call to |
xstp |
Stopping points; if |
binsz |
Target bin size, i.e., the number of points falling into each bin; for example, |
verbose |
When |
Value
A list with the following items:
binlo - The "low" value falling into the bin.
binhi - The "high" value falling into the bin.
binct - The number of points falling into the bin.
xtbl - The result of a call to
table(x)
.xval - The sorted unique values of the data points x. Essentially, a numeric version of
names(xtbl)
.
See Also
binr
, bins
, bins.quantiles
bins.optimize