Refactor to reduce extra calls to total_examples() and calculations of the uniform category probability