So, with the bin filling decisions, do we want hoe many ordered lists there are, or how many unordered sets there are? Changing the order of the decisions doesn't make a new possible outcome. To calculate how many possible outcomes there are, we keep the decision order fixed. So, we want combinations here. The number of ways to fill a histogram bin to binheight appears to be (sampcount C binheight) popcount ^ (sampcount - binheight), but I'm not sure !