I think this loop can be vectorized, something like
```python
ii = np.random.randint(M, size=(N, M))
bsData = data[ii]
estimate = np.median(bsData, axis=1, overwrite_input=True)
```
It looks like the input ``data`` is 1-D, correct?