Generating a categorical value

A random category can be generated from a rectangularly distributed random value, r .

If P(success) is denoted by the symbol π, then a success will be generated if r is less than π. This can be generalised as illustrated in the diagram below: