Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- x<-rnorm(2400,0, 3)
- y<-rnorm(400,0,3)
- no_row<-length(x)
- no_col<-length(y)
- input<-matrix(data=1,nrow = no_row, ncol = no_col)
- result<-matrix(nrow = no_row, ncol = no_col)
- calculation<-function(x,y)
- {
- for(i in 1:no_row)
- {
- for(j in 1:no_col)
- {
- z<-exp(x[i]-y[j])
- result[i,j]<-(z/1+z)
- }
- }
- residual<-input-result
- sq_sum_residulas<-sum((rowSums(residual, na.rm = T))^2)
- if(sq_sum_residulas>=1){calculation(x,y)}
- else(return(residual))
- }
- output<-calculation(x,y)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement