decode: En-/decodes values to/from ranges of -1 to 1.

Description Usage Arguments Details Value Author(s) Examples

View source: R/utils.R

Description

Encode and decode values that are in a range of -1 to 1 into a specified range.

Usage

1
2
3
	encode(value, bounds)
	decode(value, bounds)
	decodeAll(values, params)

Arguments

value

A value

values

A vector with values in the range [-1,1]

bounds

A vector of two values defining the lower and upper bound of a range.

params

A list where evere list-item consist of two values defining a lower and an upper bound.

Details

Decodes a values from ranges of -1 to 1 to ranges specified.

A function used to decode values that are in a range of -1 to 1 into a specified range. For every value a list item with lower and upper bound has to be supplied.

A function used to encode values that are in a specified range into a range between -1 to 1.

Value

decode: The encoded value. decodeAll: A vector of decoded values.

Author(s)

Gunnar Libiseller

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
	decode(0, c(10, 20))
	decode(-0.5, c(10, 20))
	decode(1, c(10, 20))
	
	bounds <- c(10, 20)
	encode(decode(1, bounds), bounds)

        ## Multiple values:
	values <- c(-1, -0.25, 0, 0.75)
	params <- getDefaultXcmsSetStartingParams()
	type_params <- typeCastParams(params)
	
	decodeAll(values, type_params$to_optimize)

        ## Combination of encode and decode
	encode(15, c(10, 20))
	encode(10, c(10, 20))
	encode(5, c(1, 5))

	bounds <- c(1,5)
	decode(encode(5, bounds), bounds)

IPO documentation built on Nov. 8, 2020, 8:31 p.m.