getRangeForDiscretizedValue {mmb}R Documentation

Get the range-/bucket-ID of a given value.

Description

Given a list of previously computed ranges for a random variable, this function returns the index of the range the given value belongs to (i.e., in which bucket it belongs). The indexes start R-typically at 1. Per definition, a value is within a range, if it is larger than the range's minimum and less than or equal to its maximum.

Usage

getRangeForDiscretizedValue(ranges, value)

Arguments

ranges

list of ranges, as obtained by @seealso discretizeVariableToRanges

value

numeric a value drawn from the previously discretized random variable.

Value

integer the index of the range the given value falls into.

Author(s)

Sebastian Hönel sebastian.honel@lnu.se

Examples

buckets <- mmb::discretizeVariableToRanges(
  data = iris$Sepal.Length, openEndRanges = TRUE)

mmb::getRangeForDiscretizedValue(
  ranges = buckets, value = mean(iris$Sepal.Length))

[Package mmb version 0.13.3 Index]