binarySearch_bin {genscore} | R Documentation |
Finds the index of the bin a number belongs to using binary search.
Description
Finds the index of the bin a number belongs to using binary search.
Usage
binarySearch_bin(arr, l, r, x)
Arguments
arr |
A vector of size at least 2. |
l |
An integer between 1 and |
r |
An integer between 1 and |
x |
A number. Must be within the range of [ |
Details
Finds the smallest index i
such that arr[i] <= x <= arr[i+1]
.
Value
The index i
such that arr[i] <= x <= arr[i+1]
.
Examples
binarySearch_bin(1:10, 1, 10, seq(1, 10, by=0.5))
binarySearch_bin(1:10, 5, 8, seq(5, 8, by=0.5))
[Package genscore version 1.0.2.2 Index]