Guest User

Untitled

a guest
Feb 18th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. g_i <- function(x, i, mu, sigma){
  2. res <- rep(NA, length(x))
  3. for(k in 1:length(x)){
  4. res[k] <- x[k]*prod(1-pnorm(x[k], mu[-i], sigma[-i]))*dnorm(x[k],mu[i],sigma[i])
  5. }
  6. return(res)
  7. }
  8.  
  9. expected_score <- function(mu, sigma){
  10. n <- length(mu)
  11. res <- sum(mu)
  12. for(i in 1:n){
  13. I_i <- integrate(g_i, lower=-Inf, upper=Inf, i=i, mu=mu, sigma=sigma)$value
  14. res <- res - I_i/sigma[i]
  15. }
  16. return(res)
  17. }
Add Comment
Please, Sign In to add comment