The procedure of Knuth and Yao to simulate random numbers with specifi
ed distribution by parsing sequences of fair coin tosses is generalize
d to employ discrete distributions of particular form instead of fair
coins. Each probability in these distributions is an integral power of
some fixed value t. The parse tree for the simulation procedure is cl
osely related to the code trees arising in Karp's optimal variable-len
gth coding algorithm for code symbols of unequal cost.