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 or equal (leq) to this value.
1 | num_leq_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. |
tolerance |
a non-negative number, indicating the tolerance for numerical noise. |
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_less_sorted
for a less-than comparison of two sorted vectors.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | # The second vector has
# -) 0 elements leq (less-than-or-equal) -3
# -) 2 elements leq 1
# -) 2 elements leq 3
# -) 3 elements leq 5
# -) 3 elements leq 7
num_leq_sorted(c(-3, 1, 3, 5, 7), c(0, 1, 4, 9, 16))
# Numerical noise < tolerance has no effect
num_leq_sorted(1, 0:2, tolerance=1e-12)
num_leq_sorted(1 - 1e-13, 0:2, tolerance=1e-12)
num_leq_sorted(1 + 1e-13, 0:2, tolerance=1e-12)
# Trivial cases
num_leq_sorted(1:5, 1:5)
num_leq_sorted(c(), 1:5)
num_leq_sorted(1:5, c())
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.