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.
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)
naive = FALSE
.n < binsz
points in the current bin already.
Also suppose that the next value V is represented by m
points, and m + n > binsz
.
Then the algorithm will check if m > thresh * binsz
, and if so, will place the value V into a new bin.
If m
is below the threshold, the points having value V are added to the current bin.TRUE
, simply calls bins.greedy.impl
with data
derived from x
. Otherwise, makes an extra step of marking the values that
by themselves take a whole bin to force the algorithm to place these values
in a bin separately.names(xtbl)
.table(x)
.xstp[i] == TRUE
, the i
-th value can't be merged to the (i-1)
-th one.
xstp[1]
value is ignored.floor(length(x) / nbins)
TRUE
, prints the number of points falling into the bins.table(x)
.
names(xtbl)
.
binr
, bins
, bins.quantiles
bins.optimize