Description Usage Arguments Value Note See Also Examples
For two sorted numeric vectors a
and b
, for each element a[i]
determine the number of elements in b
that are less than this value.
1 | num_less_sorted(a, b, tolerance = 0)
|
a |
a sorted, i.e. non-decreasing, vector of numbers. |
b |
a sorted, i.e. non-decreasing, vector of numbers. |
An integer vector of same length as a
.
Equivalently, because the input vectors are sorted, for each element a[i]
determine the maximum index j
with b[j] < a[i]
.
num_leq_sorted
for a less-than-or-equqal comparison of two sorted vectors.
1 2 3 4 5 6 7 8 9 10 11 12 | # The second vector has
# -) 0 elements less than -3
# -) 1 element less than 1
# -) 2 elements less than 3
# -) 3 elements less than 5
# -) 3 elements less than 7
num_less_sorted(c(-3, 1, 3, 5, 7), c(0, 1, 4, 9, 16))
# Trivial cases
num_less_sorted(1:5, 1:5)
num_less_sorted(c(), 1:5)
num_less_sorted(1:5, c())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.