我试图区分函数f_Current_theta和Current_theta,但输出了以下错误:
f_current_theta <- function(current_theta) {
if(current_theta > 0){
result <- -log(sqrt(2) * exp(-2*current_theta) / pi * sqrt(current_theta))
return(result)
} else {
result <- -log(0)
return(result)
}
}
U_grad <- Deriv::Deriv(f_current_theta)
Error in Deriv_(a, x[ix], env, use.D, dsym, scache, drule. = drule.) :
Could not retrieve body of 'return()'
为什么它不能检索到‘Return’的正文?