sampleStep {tilingArray} | R Documentation

## 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.

### 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]<step` are dropped. Then, `i` is set to the smallest j with `x[j]-x[i]>=step`.

### Value

A logical vector of the same length as `x`, representing the selected subsample.

### Author(s)

W. Huber <huber@ebi.ac.uk>

### Examples

     x   = sort(as.integer(runif(20)*100))
     sel = sampleStep(x, step=10)
     x
     x[sel]

[Package tilingArray version 1.22.0 Index]