I run into a function but not quite understand it. I am not sure it is a convention or has a meaning. what does the _p, where did the _p enter the function. It would be much appreciated if you can give me some explanation on the for loop here.
def contraction_mapping(S, p, MF, params, beta=0.75, threshold=1e-6, suppr_output=False): ''' Initialization of the state-transition matrices: describe the state-transition probabilities if the maintenance cost is incurred, and regenerate the state to 0 if the replacement cost is incurred. ''' ST_mat = np.zeros((S, S)) p = np.array(p) for i in range(S): for j, _p in enumerate(p): if i + j < S-1: ST_mat[i+j][i] = _p elif i + j == S-1: ST_mat[S-1][i] = p[j:].sum() else: pass R_mat = np.vstack((np.ones((1, S)),np.zeros((S-1, S))))
pvariable. This is generally bad practice (precisely because it harms readability and results in questions like this!), but to each their own._, it's possible to describe the ignored variable. E.g.[(x,z) for x, _y, z in coordinates].