alloc: Allocate values to "buckets" subject to weights and...

View source: R/utils.R

allocR Documentation

Allocate values to "buckets" subject to weights and constraints

Description

Allocates tgt of something to length(bucketLims) different "buckets" subject to the constraint that each bucket has a maximum value of bucketLims that cannot be exceeded. By default counts are distributed equally between buckets, but weights can be provided using ws to have the redistribution prefer certain buckets over others.

Usage

alloc(tgt, bucketLims, ws = rep(1/length(bucketLims), length(bucketLims)))

Arguments

tgt

Value to distribute between buckets.

bucketLims

The maximum value that each bucket can take. Must be a vector of positive values.

ws

Weights to be used for each bucket. Default value makes all buckets equally likely.

Value

A vector of the same length as bucketLims containing values distributed into buckets.


SoupX documentation built on Nov. 1, 2022, 5:05 p.m.