env_dif | R Documentation |
Differentiable helper functions available to any gadget3 model
These functions are part of g3_env
is the top-level environment that any gadget3 model uses.
dif_pmax(a, b, scale)
Returns the maximum of a & b. If a is a vector/array, then all members of a are compared against b. If b is also a vector, then all members of a are compared against the matching member of b (repeating b if necessary).
scale influences the sharpness of inflection points, should be about 1e5, depending on ranges of input values.
dif_pmin(a, b, scale)
Returns the minimum of a & b, otherwise works like dif_pmax
.
scale influences the sharpness of inflection points, should be about 1e5, depending on ranges of input values.
dif_pminmax(a, lower, upper, scale)
Returns values of a bounded between lower & upper.
scale influences the sharpness of inflection points at lower & upper, should be about 1e5, depending on ranges of input values.
## dif_pmax
g3_eval(quote( dif_pmax(1:10, 5, 1e5) ))
g3_eval(quote( dif_pmax(1:10, c(4, 7), 1e5) ))
g3_eval(quote( dif_pmax(array(1:9, dim = c(3,3)), c(3,6,8), 1e5) ))
## dif_pmin
g3_eval(quote( dif_pmin(1:10, 5, 1e5) ))
g3_eval(quote( dif_pmin(1:10, c(4, 7), 1e5) ))
## dif_pminmax
g3_eval(quote( dif_pminmax(1:10, 3, 6, 1e5) ))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.