I have a pair of equal length numpy arrays. dwells contains float numbers representing dwell times, and ids represents a state. In my example there are only 3 unique states labeled 0, 1, 2.
dwells = np.array([4.3,0.2,3,1.5])
ids = np.array([2, 0, 1, 2])
Previous 2 arrays model a system that starts in state 2, stays there for 4.3 seconds, jumps to state 0, stays for 0.2 seconds and so on.
I would like to generate another numpy array. It needs as many columns as dwells.sum(), each representing a whole number 0,1,2,3... indicating time. Each row matches one of the unique states (in this case 3). Each element of this array represents the relative contribution of each state during that time. For example, during the first 4 time points, only state 2 has any contribution, and thus the 1st 4 elements of row 2 are equal to 1. The fifth column has contribution from all 3 states but the sum equals 1.
[[0, 0, 0, 0, 0.2, 0, 0,  0,  0]
 [0, 0, 0, 0, 0.5, 1, 1, 0.5, 0]
 [1, 1, 1, 1, 0.3, 0, 0, 0.5, 1]]
I could do that with a for loop but I wonder if there is a more efficient vectorized way.
0.1your smallest possible time step?dwellscan have any length, even arbitrarily smallnumba.