Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- transition <- function(train, state){
- n <- NROW(train)
- b <- which(train$cl[-n] == state)
- if((NROW(b) == 0)){
- state <- train$cl[n]
- b <- which(train$cl[-n] == state)
- if((NROW(b) == 0) && (state > 1)){
- state <- sample(train$cl[-n], 1)
- b <- which(train$cl[-n] == state)
- if(NROW(b) == 0){
- b <- n
- }
- }
- }
- if((NROW(b) == 0)){
- stop("error")
- }
- new_state_position <- sample(b, 1)
- train$cl[new_state_position + 1]
- }
- def transition(train, state):
- n = len(train)
- b = train['-n'] == state
- if((len(b)==0)):
- state = train['n']
- b = train['-n'] == state
- if((len(b)==0) and (state > 1)):
- state = train['-n'].sample(n=1)
- b = train['-n'] == state
- if(len(b) == 0):
- b = n
- if(len(b) == 0):
- print('error')
- new_state_position = b.sample(n=1)
- train['new_state_position'+1]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement