normalize.vector {ppls} | R Documentation |
Normalize a Numeric Vector to Unit Length
Description
Returns the input vector normalized to have unit Euclidean norm (i.e., length equal to 1).
Usage
normalize.vector(v)
Arguments
v |
A numeric vector. |
Details
This function performs:
v_\text{normalized} = \frac{v}{\sqrt{\sum v_i^2}}
It is primarily used to normalize weight vectors or component directions in Partial Least Squares algorithms.
Note: If the input vector has zero norm, the function returns NaN
due to division by zero.
Value
A numeric vector of the same length as v
, with unit norm.
See Also
penalized.pls
, penalized.pls.default
, penalized.pls.kernel
Examples
v <- c(3, 4)
normalize.vector(v) # returns c(0.6, 0.8)
v2 <- rnorm(10)
sqrt(sum(normalize.vector(v2)^2)) # should be 1
[Package ppls version 2.0.0 Index]