# How to generate numbers from a Pareto distribution? [closed]

I need to generate numbers from a Pareto distribution (https://en.wikipedia.org/wiki/Pareto_distribution) for a game I'm making. Ideally with xm=10, and alpha = 2, but approximately is good enough. Is there anyway I can do this? I want to do it an "analogue" way (like with dice, cards, etc.) Thank you.

• What would be your ideal level of precision? i.e. if I came up with a 'perfect' answer that gave you real-valued random samples with infinite digits after the decimal, how many of those digits would you actually use? – Benjamin Cosman Aug 14 '20 at 23:48
• @BenjaminCosman Integer is good enough. – Eriek Aug 15 '20 at 0:12

One way you could sort of accomplish this for any distribution is to pre-compute a large number of samples (through any method, pulled either at random or evenly spaced) and then put them in a table indexed by your choice of analog randomizer. For example, put 100 samples in a 10x10 grid, and then have players roll two 10-sided dice and look up the corresponding value.

I suggest you stop reading now :) but here's a silly alternate answer which gets you arbitrarily close to the exact distribution for a fixed level of precision and maximum value. Pick your precision - say, integers - so then pre-compute the values of the CDF at each integer up to your maximum. For Pareto, the first few values look like:

10: 0

11: 0.173553719

12: 0.3055555556

13: 0.4082840237

Give this table to the players. Then to pull from the distribution, repeatedly roll a d10 to generate digits of a real number, and stop when you can tell which thresholds it's between. So for example if the first roll is a 2 then you can stop immediately with result 11, because every real beginning with 0.2 is between the 11 and 12 thresholds. But if the first roll is a 3 then you have to roll again - after say 3-0-0 you would have the result 11, but 3-1 or 3-0-6 would be a 12 and for 3-0-5 you'd have to keep rolling. In this way you will achieve exactly a probability of 0.173553719 of drawing a 10, etc.

• One possible variant of this: precompute 100 samples by generating samples from the Pareto inverse transform sampling function by choosing U = 1/n for n ranging from 0 to 99. Then each roll results in the corresponding sample. – murgatroid99 Aug 15 '20 at 3:07
• That's what I meant by "evenly spaced" samples; thanks for elaborating since this was obviously not clear enough from my answer :) – Benjamin Cosman Aug 15 '20 at 3:44
• Now I'm rereading my comment, though, and I wrote it wrong. It should be U=n/100, not 1/n. – murgatroid99 Aug 15 '20 at 4:22