Normalize a Vector to range -1 to +1

Description

Each value of the vector passed to the function is divided by the square root of the sum of every value squared, producing a new vector whose range is restricted to, at most, -1 to +1. Note that this assumes that the mean of the original vector is zero. An internal function, not generally called by the user.

Usage

1

Arguments

x

A numeric argument whose values are to be normalized.

Value

The normalized vector.

Note

The idea was taken from "An Introduction to rggobi" found at the ggobi web site: http://www.ggobi.org.

Author(s)

Bryan A. Hanson, DePauw University.

References

https://github.com/bryanhanson/ChemoSpec

Examples

1
2
3
4
5
6
7
x1 <- rnorm(20, 2, 2)
range(x1)
sd(x1)/diff(range(x1))

x2 <- normVec(x1)
range(x2)
sd(x2)/diff(range(x2))

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.