normalize | R Documentation |
Normalizes a character vector to a unit vector
normalize(x)
x |
a numeric or integer vector |
The (euclidean) norm of a vector x
is defined as
||x|| = \sqrt{\Sigma(x^2)}
To normalize a vector to a unit vector u
with ||u|| = 1
, the following equation is applied:
x' = x/ ||x||
The normalized vector as a numeric
Fritz Guenther
normalize(1:2)
## check vector norms:
x <- 1:2
sqrt(sum(x^2)) ## vector norm
sqrt(sum(normalize(x)^2)) ## norm = 1
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.