def get_new_state(self, state_idx=None, idx_type='obs', diabetic_idx=None):
    "\n        use to start MDP over.  A few options:\n\n        Full specification:\n        1. Provide state_idx with idx_type = 'obs' + diabetic_idx\n        2. Provide state_idx with idx_type = 'full', diabetic_idx is ignored\n        3. Provide state_idx with idx_type = 'proj_obs' + diabetic_idx*\n\n        * This option will set glucose to a normal level\n\n        Random specification\n        4. State_idx, no diabetic_idx: Latter will be generated\n        5. No state_idx, no diabetic_idx:  Completely random\n        6. No state_idx, diabetic_idx given:  Random conditional on diabetes\n        "
    assert (idx_type in ['obs', 'full', 'proj_obs'])
    option = None
    if (state_idx is not None):
        if ((idx_type == 'obs') and (diabetic_idx is not None)):
            option = 'spec_obs'
        elif ((idx_type == 'obs') and (diabetic_idx is None)):
            option = 'spec_obs_no_diab'
            diabetic_idx = np.random.binomial(1, self.p_diabetes)
        elif (idx_type == 'full'):
            option = 'spec_full'
        elif ((idx_type == 'proj_obs') and (diabetic_idx is not None)):
            option = 'spec_proj_obs'
    elif ((state_idx is None) and (diabetic_idx is None)):
        option = 'random'
    elif ((state_idx is None) and (diabetic_idx is not None)):
        option = 'random_cond_diab'
    assert (option is not None), 'Invalid specification of new state'
    if (option in ['random', 'random_cond_diab']):
        init_state = self.generate_random_state(diabetic_idx)
        while init_state.check_absorbing_state():
            init_state = self.generate_random_state(diabetic_idx)
    else:
        init_state = State(state_idx=state_idx, idx_type=idx_type, diabetic_idx=diabetic_idx)
    return init_state
use to start MDP over.  A few options:

Full specification:
1. Provide state_idx with idx_type = 'obs' + diabetic_idx
2. Provide state_idx with idx_type = 'full', diabetic_idx is ignored
3. Provide state_idx with idx_type = 'proj_obs' + diabetic_idx*

* This option will set glucose to a normal level

Random specification
4. State_idx, no diabetic_idx: Latter will be generated
5. No state_idx, no diabetic_idx:  Completely random
6. No state_idx, diabetic_idx given:  Random conditional on diabetes
def get_new_state(self, state_idx=None, idx_type='obs', diabetic_idx=None):
    "\n        use to start MDP over.  A few options:\n\n        Full specification:\n        1. Provide state_idx with idx_type = 'obs' + diabetic_idx\n        2. Provide state_idx with idx_type = 'full', diabetic_idx is ignored\n        3. Provide state_idx with idx_type = 'proj_obs' + diabetic_idx*\n\n        * This option will set glucose to a normal level\n\n        Random specification\n        4. State_idx, no diabetic_idx: Latter will be generated\n        5. No state_idx, no diabetic_idx:  Completely random\n        6. No state_idx, diabetic_idx given:  Random conditional on diabetes\n        "
    assert (idx_type in ['obs', 'full', 'proj_obs'])
    option = None
    if (state_idx is not None):
        if ((idx_type == 'obs') and (diabetic_idx is not None)):
            option = 'spec_obs'
        elif ((idx_type == 'obs') and (diabetic_idx is None)):
            option = 'spec_obs_no_diab'
            diabetic_idx = np.random.binomial(1, self.p_diabetes)
        elif (idx_type == 'full'):
            option = 'spec_full'
        elif ((idx_type == 'proj_obs') and (diabetic_idx is not None)):
            option = 'spec_proj_obs'
    elif ((state_idx is None) and (diabetic_idx is None)):
        option = 'random'
    elif ((state_idx is None) and (diabetic_idx is not None)):
        option = 'random_cond_diab'
    assert (option is not None), 'Invalid specification of new state'
    if (option in ['random', 'random_cond_diab']):
        init_state = self.generate_random_state(diabetic_idx)
        while init_state.check_absorbing_state():
            init_state = self.generate_random_state(diabetic_idx)
    else:
        init_state = State(state_idx=state_idx, idx_type=idx_type, diabetic_idx=diabetic_idx)
    return init_state