Unlimited learning, half price | 50% off
Get 50% off unlimited learning

AssocBin (version 1.1-0)

maxScoreSplit: Size-restricted bivariate score maximizing splitting

Description

Splits a bin based on the location maximizing a score function with restrictions on minimum bin size.

Usage

maxScoreSplit(bin, scorer, minExp = 5, squarify = FALSE)

Value

A list of two bins resulting from the split of `bin` along the corresponding margin at the maximum location

Arguments

bin

a bin to be split with elements `x`, `y`, `depth`, `bnds` (list with elements `x` and `y`), `expn`, `n`

scorer

function which accepts a numeric vector of potential split coordinates and the bounds of `bin` and returns a numeric vector of scores for each

minExp

value giving the smallest expected count allowed for bin splits

squarify

logical value, should we force splitting on the longer side regardless of scores?

Author

Chris Salahub

Details

This function serves as a wrapper which manages the logic of splitting bins using a score function while maintaining a minimum size and allowing forced splits along the wider edge.

Examples

Run this code
bin <- makeBin(x = 1:10, y = sample(1:10))
maxScoreSplit(bin, chiScores)
maxScoreSplit(bin, miScores) # pretty similar for both
maxScoreSplit(bin, randScores)
maxScoreSplit(bin, randScores) # different every time

Run the code above in your browser using DataLab