Added a subroutine to generate random results from a discrete probability mass function.