Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. x<-rnorm(2400,0, 3)
  2. y<-rnorm(400,0,3)
  3. no_row<-length(x)
  4. no_col<-length(y)
  5. input<-matrix(data=1,nrow = no_row, ncol = no_col)
  6. result<-matrix(nrow = no_row, ncol = no_col)
  7. calculation<-function(x,y)
  8. {
  9. for(i in 1:no_row)
  10. {
  11. for(j in 1:no_col)
  12. {
  13. z<-exp(x[i]-y[j])
  14. result[i,j]<-(z/1+z)
  15. }
  16. }
  17. residual<-input-result
  18. sq_sum_residulas<-sum((rowSums(residual, na.rm = T))^2)
  19. if(sq_sum_residulas>=1){calculation(x,y)}
  20. else(return(residual))
  21. }
  22. output<-calculation(x,y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement