Nothing
## File Name: numerical_Hessian_partial.R
## File Version: 0.15
numerical_Hessian_partial <- function(par, FUN, h=1E-5, coordinate=1, ... )
{
ii <- coordinate
f0 <- FUN( x=par, ... )
#** select h parameters according to size of parameters
abs_par <- abs(par)
hvec <- h * ifelse( abs_par > 1, abs_par, 1 )
#--- for computing f(x+h)
par1 <- par
par1[ii] <- par[ii] + hvec[ii]
f1 <- FUN( x=par1, ...)
#--- computation x-h
par1[ii] <- par[ii] - hvec[ii]
f2 <- FUN( x=par1, ...)
#--- gradient and Hessian
grad <- (f1 - f2 ) / (2*hvec[ii])
hessian <- (f1 + f2 - 2*f0) / hvec[ii]^2
#--- output
res <- list( f0=f0, f1=f1, f2=f2, grad=grad, hessian=hessian)
return(res)
}
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.