Check sample size and move computeFraction

Check that the sample size is within supported range. Moved
computeFraction int a private util class in util.random