Related to this question I recently posted & resolved.
If the 3rd column of a matrix is to be changed to be the running total of the sums, how would I adjust my code to do so? This is where I'm at so far:
def dice(n):
    rolls = np.empty(shape=(n, 3),dtype=int)
    for i in range(n):
        x = random.randint(1,6)
        y = random.randint(1,6)
        if x in [1,3,5] or y in [1,3,5]:      
            sum_2_dice = x + y 
            z = np.cumsum(sum_2_dice)
            rolls[i,:] = x, y, z
        else:
            sum_2_dice = -(x+y)  # meaning you "lose the sum" basically
            z = np.cumsum(sum_2_dice)
            rolls[i,:] = x, y, z
    return rolls `
So for example: dice(2)
returns
array[[2, 6, -8],
      [1, 3,  4],
      [5, 2,  7])
when it should really be returning:
array[[2, 6, -8],
      [1, 3, -4],
      [5, 2,  3])
I thought np.cumsum would be doing something, but I'm not sure. Is a while loop needed to do this (I'm not sure of where it'd be applied)? I've tried various adjustments like instead of having z = np.cumsum(sum_2_dice) I did sum_2_dice += sum_2_dice (consequently the code that followed it was rolls[i,:] = x, y, sum_2_dice but that was terribly wrong since all that ended up doing was doubling the sum values in every column, not doing any sort of running total calculations.
 
     
    