Skip to contents

Soft-thresholding operator

Usage

soft(x, l)

Arguments

x

The thing to be thresholded

l

The threshold; must either be length 1 or same langth as x

Examples

soft(-10:10, 2.5)
#>  [1] -7.5 -6.5 -5.5 -4.5 -3.5 -2.5 -1.5 -0.5  0.0  0.0  0.0  0.0  0.0  0.5  1.5
#> [16]  2.5  3.5  4.5  5.5  6.5  7.5
soft(rep(5.5, 10), 1:10)
#>  [1] 4.5 3.5 2.5 1.5 0.5 0.0 0.0 0.0 0.0 0.0
soft(matrix(1:30, ncol=3), 10)
#>       [,1] [,2] [,3]
#>  [1,]    0    1   11
#>  [2,]    0    2   12
#>  [3,]    0    3   13
#>  [4,]    0    4   14
#>  [5,]    0    5   15
#>  [6,]    0    6   16
#>  [7,]    0    7   17
#>  [8,]    0    8   18
#>  [9,]    0    9   19
#> [10,]    0   10   20