Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. one_plus_one<-function(f,sigma,nbEvals,precision){
  2. m=runif(2,min = -5,max = 5)
  3. i=0
  4. out<-f(m)
  5. repeat{
  6. x1 = m[1] +rnorm(n=1, mean=0,sd=sigma)
  7. x2 = m[2]+rnorm(n=1, mean=0,sd=sigma)
  8. #cat(f(c(x1,x2)),"//",f(m),"||")
  9. if(f(c(x1,x2)) < f(m)){
  10. m<-c(x1,x2)
  11. sigma=sigma*exp(1/3)
  12. }else{
  13. sigma=sigma/exp(1/4)^(1/4)
  14. }
  15. out<-c(out,f(m))
  16. i <- i + 1
  17. if (i>nbEvals | f(m)<precision){break}
  18. }
  19. return(out)
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement