Remember to simulate to find more mistakes. (popbinheight^sampbinheight) (popcount - popbinheight) ^ (sampcount - sampbinheight) (sampcount C sampbinheight) I'm thinking that if we wanted to consider the number of samplings that made the whole precise histogram, we would replace the larger exponent with further copies of the rest of the expression, where sampcount is reduced appropriately in each. Is there an error, because popcount is not present in the result? Not sure. Popcount is needed to know the probability of getting one of the bins, but we are already assuming that we got them all ....