soft_l2norm: Soft-threshold and normalize

Description Usage Arguments Details Examples

View source: R/utilities.R

Description

Soft-threshold, and then normalize the result to L2-norm of 1. Care is taken with vectors of L2-norm empirically equal to zero.

Usage

1
soft_l2norm(x, lambda)

Arguments

x

Vector to be soft-thresholded

lambda

Threshold value

Details

This function is not exported, as it is an internal utility function. Use spca:::soft_l2norm to access it.

Examples

1
2
3
4
5
6
7
8
set.seed(1)
(z <- rnorm(10))
spca:::soft_l2norm(z, 0.5)
sqrt(sum(spca:::soft_l2norm(z, 0.5)^2))

(z <- rnorm(100))
spca:::soft_l2norm(z, 0.75)
sqrt(sum(spca:::soft_l2norm(z, 0.5)^2))

schoonees/spca documentation built on Jan. 31, 2021, 6:21 p.m.