threshold: Threshold a matrix/vector below and above

Description Usage Arguments See Also Examples

View source: R/threshold.R

Description

threshold sets values of a vector/matrix below min to min; values above max are set to max.

threshold is mainly used to project sparsified weight vectors (sparsify_weights) back onto the probability simplex (thus min = 0 and then normalize).

Usage

1
threshold(x, min = -Inf, max = Inf)

Arguments

x

a numeric matrix(like object)

min

minimum value

max

maximum value

See Also

normalize

Examples

1
print(threshold(c(1, 4, 2, -1, 10), min = 0))

Example output

[1]  1  4  2  0 10

LICORS documentation built on May 1, 2019, 10:13 p.m.