[0aeb11]: / soft.shrink.R

Download this file

10 lines (9 with data), 237 Bytes

1
2
3
4
5
6
7
8
9
soft.shrink <-
function (delta, threshold)
{
dif <- abs(delta) - threshold
delta <- sign(delta) * dif * (dif > 0)
nonzero <- sum(drop((dif > 0) %*% rep(1, ncol(delta))) > 0)
attr(delta, "nonzero") <- nonzero
delta
}