normalize: Normalize a vector

Description Usage Arguments Details Value Author(s) Examples

Description

Normalizes a character vector to a unit vector

Usage

1

Arguments

x

a numeric or integer vector

Details

The (euclidean) norm of a vector x is defined as

||x|| = √{Σ(x^2)}

To normalize a vector to a unit vector u with ||u|| = 1, the following equation is applied:

x' = x/ ||x||

Value

The normalized vector as a numeric

Author(s)

Fritz Günther

Examples

1
2
3
4
5
6
7
8
9
normalize(1:2)


## check vector norms:

x <- 1:2

sqrt(sum(x^2))              ## vector norm
sqrt(sum(normalize(x)^2))   ## norm = 1

codymarquart/LSAfun documentation built on May 13, 2019, 8:47 p.m.