Advertisement
Guest User

Untitled

a guest
Aug 16th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. transition <- function(train, state){
  2. n <- NROW(train)
  3. b <- which(train$cl[-n] == state)
  4.  
  5. if((NROW(b) == 0)){
  6. state <- train$cl[n]
  7. b <- which(train$cl[-n] == state)
  8.  
  9. if((NROW(b) == 0) && (state > 1)){
  10. state <- sample(train$cl[-n], 1)
  11. b <- which(train$cl[-n] == state)
  12.  
  13. if(NROW(b) == 0){
  14. b <- n
  15. }
  16. }
  17. }
  18.  
  19. if((NROW(b) == 0)){
  20. stop("error")
  21. }
  22. new_state_position <- sample(b, 1)
  23. train$cl[new_state_position + 1]
  24. }
  25.  
  26. def transition(train, state):
  27. n = len(train)
  28. b = train['-n'] == state
  29. if((len(b)==0)):
  30. state = train['n']
  31. b = train['-n'] == state
  32.  
  33. if((len(b)==0) and (state > 1)):
  34. state = train['-n'].sample(n=1)
  35. b = train['-n'] == state
  36.  
  37. if(len(b) == 0):
  38. b = n
  39. if(len(b) == 0):
  40. print('error')
  41. new_state_position = b.sample(n=1)
  42. train['new_state_position'+1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement