Given a vector D and a same-size integer vector S of subset indices,
return the mean of D within each subset:
i is the mean of the D values whose S entry equals ii runs from 0 up to the largest value in SInput
D = [0. 1. 2. 3. 4. 5. 6. 7. 8. 9.]
S = [0 1 2 3 0 1 2 3 0 1]
Output
[4. 5. 4. 5.]