powered by
Estimates the derivate (or gradient) of the function fn with respect to the argument x
fn
x
# S3 method for numeric dfun(x, fn)# S3 method for array dfun(x, fn)dfun(x, fn)
# S3 method for array dfun(x, fn)
dfun(x, fn)
input numeric
numeric
function
Returns the gradient of x
# NOT RUN { fn = function(x)x**2 ## On scalar arguments dx_scalar = dfun(3, fn) print(dx_scalar) ## On matrix (or arrays) dx_array = dfun(matrix(c(3, 3, 3, 3), 2, 2), fn) print(dx_array) # }
Run the code above in your browser using DataLab