hard_threshold()
implements the hard-thresholding operator on a given
matrix D
, making D
sparser: elements of D
whose absolute value are less
than a given threshold thresh
are set to 0, i.e. \(D[|D| < thresh] = 0\).
This is used in the non-convex PCP function rrmc()
to provide a non-convex
replacement for the prox_l1()
method used in the convex PCP function
root_pcp()
. It is used to iteratively model the sparse S
matrix with the
help of an adaptive threshold (thresh
changes over the course of
optimization).
Examples
set.seed(42)
D <- matrix(rnorm(25), 5, 5)
S <- hard_threshold(D, thresh = 1)
D
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.3709584 -0.10612452 1.3048697 0.6359504 -0.3066386
#> [2,] -0.5646982 1.51152200 2.2866454 -0.2842529 -1.7813084
#> [3,] 0.3631284 -0.09465904 -1.3888607 -2.6564554 -0.1719174
#> [4,] 0.6328626 2.01842371 -0.2787888 -2.4404669 1.2146747
#> [5,] 0.4042683 -0.06271410 -0.1333213 1.3201133 1.8951935
S
#> [,1] [,2] [,3] [,4] [,5]
#> [1,] 1.370958 0.000000 1.304870 0.000000 0.000000
#> [2,] 0.000000 1.511522 2.286645 0.000000 -1.781308
#> [3,] 0.000000 0.000000 -1.388861 -2.656455 0.000000
#> [4,] 0.000000 2.018424 0.000000 -2.440467 1.214675
#> [5,] 0.000000 0.000000 0.000000 1.320113 1.895193