search_bin: Finds the index of the bin a number belongs to.

View source: R/rand_gen.R

search_binR Documentation

Finds the index of the bin a number belongs to.

Description

Finds the index of the bin a number belongs to.

Usage

search_bin(arr, x)

Arguments

arr

A vector of size at least 2.

x

A number. Must be within the range of [arr[1], arr[length(arr)]].

Details

Finds the smallest index i such that arr[i] <= x <= arr[i+1]. Calls binarySearch_bin() if length(arr) > 8 and calls naiveSearch_bin() otherwise.

Value

The index i such that arr[i] <= x <= arr[i+1].

Examples

search_bin(1:10, seq(1, 10, by=0.5))

genscore documentation built on May 29, 2024, 9 a.m.