Learn R Programming

SomatiCA (version 2.2.0)

denoise: Smoothing procedure by replacing outliers.

Description

Smoothing procedure by replacing outliers (defined by deviations from mean) with median in a sliding window.

Usage

denoise(data, k = 30, t = 2)

Arguments

data
A numeric vector.
k
Define window size.
t
The number of standard deviation used to define outliers.

Value

Smoothed data, a numeric vector.

Examples

Run this code
x <- c(rnorm(200, 0.4, 0.05), rnorm(200, 0.1, 0.05)) 
x[round(runif(20)*400)] <- rnorm(20, 0.2, 0.05)
x[round(runif(20)*400)] <- rnorm(20, 0.3, 0.05)
y <- denoise(x)
plot(x)
points(y, pch=20, col="red")

Run the code above in your browser using DataLab