def simulate(self, sim_length): """ simulate the patient over the specified simulation length """ # random number generator for this patient self._rng = rndClasses.RNG(self._id) k = 0 # current time step # while the patient is alive and simulation length is not yet reached while self._stateMonitor.get_if_alive( ) and k * self._delta_t < sim_length: # find the transition probabilities of the future states trans_probs = self._param.get_transition_prob( self._stateMonitor.get_current_state()) # create an empirical distribution empirical_dist = rndClasses.Empirical(trans_probs) # sample from the empirical distribution to get a new state # (returns an integer from {0, 1, 2, ...}) new_state_index = empirical_dist.sample(self._rng) # update health state self._stateMonitor.update(k, P.HealthStats(new_state_index)) # increment time step k += 1