The "hard way" isn't really too hard: raw = uniform(0); cat = (raw > .5) + (raw > .7);