Using take is significantly faster
```
cumulative_p_w_sample = np.cumsum(p_w_c.take(y, axis=1).sum(axis=1))
```