nrm: (normalizes) recalibrates the vector between two said values

View source: R/nrm.R

nrmR Documentation

(normalizes) recalibrates the vector between two said values

Description

This function takes in a vector and outputs a recalibrated vector according to the min and max values set in the function argument. The min and the max values are set to min=0 and max=1 by default. Hence the name nrm(X)

Usage

nrm(x, min, max)

Arguments

x

denotes the vector that needs recalibration

min

denotes the minimum value of the vector that you want to recalibrate your input vector(X) to. Default set to min=0.

max

denotes the maximum value of the vector that you want to recalibrate your input vector(X) to. Default set to max=1.

Author(s)

Chitran Ghosal

Examples

##testing the function1
vec_in <- c(1,1.5,3)
vec_out <- nrm(vec_in, min = 2, max = 100)

##testing the function2
t <- seq(-11,11, by=0.05)
y <- 35*sin(0.05*t)*cos(t+0.75)
par(mfrow=c(2,1))
plot(t,y,type = 'b' )
y <- nrm(y)
plot(t,y, col='red', typ='l')
########################################
## The function is currently defined as
nrm <- function(X, min=0, max=1){
  Y <- ((max - min)/(max(X) - min(X)))*(X - min(X)) + min
  return(Y)
}


Chitran1987/StatsChitran documentation built on Feb. 23, 2025, 8:30 p.m.