downsample_digital_timeseries | R Documentation |
When downsampling integers, it is difficult to decide on what value should be retained since simpler subsampling approaches may retain a digital value that is not representative of the local neighborhood of the vector. This is less of a problem for downsampling of analog channels where we assume relative continuity across values.
Here, we have adopted the approach of downsampling integers by retaining the most common intger value within each subset of the vector. For example, if the vector is of length 100 and we are downsampling 10x, then the function will look within each set of 10 integers and retain the most common value in each.
x |
A vector of integer values to be downsampled by retaining the mode in each chunk |
downsamp |
The factor by which data are downsampled (e.g., 3 will reduce the resulting vector 3x) |
demote_zeros |
Logical indicating whether to prefer non-zero modes, even if they are no more likely in a chunk |
Note that this function does not allow for multiple modes. If there are multiple modes, it always
retains the mode with the lowest integer value in each chunk. The exception is if demote_zeros
is TRUE
.
In this case, even if there is one non-zero value in a chunk, it will trump any number of zeros. This is helpful for
TTL codes where a code may be on for part of the higher-frequency time series and we don't want it to become zero
in the downsampled data.
A vector of length ceiling(length(x)/downsamp)
with downsampled integers
Michael Hallquist
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.