sampleStep: Sampling of ascending numbers to ensure minimal spacing.
Description
Given a vector of ascending numbers and a step width, sample the
numbers such that the difference between consecutive numbers is greater
than or equal to step.
Usage
sampleStep(x, step)
Arguments
x
Numeric or integer vector.
step
Numeric scalar.
Value
A logical vector of the same length as x, representing the
selected subsample.
Details
The simple algorithm works greedily from x[1] to
x[length(x)]. First, x[1] is selected. Then, if x[i]
is selected, all numbers x[j] with j>i and
x[j]-x[i] are dropped. Then, i is set to the
smallest j with x[j]-x[i]>=step.