My main question is whether vectorising these length-sampling operations is worthwhile, given that it makes the code arguably a bit less readable, and the overall cost is still dominated by looping through each sample.