R <-6
N <- 13
Nb <- 4
S_norm <- 0.3
Ao <- 1/8.02e-5
exact_likelihood <- function(psi){
exact_likelihood_function <- function(logA){
sum_p = 0
for (k in seq(N)){
r <- (exp(logA)*psi)**k
sum_p <- r + sum_p
}
return(exp(-0.5*(((logA - log(Ao))/S_norm)**2)) * exp(-exp(logA)*psi) * sum_p)
}
return(integrate(exact_likelihood_function,-Inf,Inf,subdivisions=1000L,abs.tol=1E-300)$value)
}
我收到错误Error in integrate(exact_likelihood_function, -Inf, Inf, subdivisions = 1000L, : non-finite function value
,不确定原因。该函数在Python中完美评估。