Skip to contents

This function applies a reverse operation of normalization for a numeric vector x based on the scale factors derived from an original vector orig_x. It effectively attempts to map the values in x back to their original scale by applying the inverse operations of scaling and translation based on the minimum and maximum values found in orig_x. The process involves scaling x by the maximum value (after subtracting the minimum value) of orig_x and then adding the minimum value of orig_x to each element.

Usage

rescale(x, orig_x)

Arguments

x

A numeric vector that needs to be rescaled to its original range.

orig_x

The original numeric vector from which the scale factors are derived.

Value

A numeric vector with values rescaled to their original range based on the scale factors from orig_x.

Examples

# Generate random values and normalize
orig_x <- rnorm(100)
normed_x <- norm01(orig_x)
# Rescale normalized values back to original range
rescaled_x <- rescale(normed_x, orig_x)
range(rescaled_x) # This should closely match the range of orig_x
#> [1] -2.808011  2.654898
range(orig_x)
#> [1] -2.808011  2.654898