Like having 1 be the most common number and 6 be the least common number. And everything else just leveling out.

  • 1
    Sharing your research helps everyone. Tell us what you've tried and why it didn’t meet your needs. This demonstrates that you’ve taken the time to try to help yourself, it saves us from reiterating obvious answers, and most of all it helps you get a more specific and relevant answer. Also see How to Ask
    – gnat
    May 20, 2014 at 7:41
  • it would no longer be random...
    – jwenting
    May 21, 2014 at 9:26

3 Answers 3


You could set up an array of say 42 integers with numbers :


You then get a true random number between 0 and 41 and the appropriate number from the array.

In the above setup a 1 is 6 times more likely to occur than a 6, and twice as likely as a three. You can play with the contents of the array to get the distribution you require.

  • Thanks. I never though about it that way. May 20, 2014 at 5:51
  • “a true random number between 0 and 41” Did you mean “uniformly distributed random number”? Because other distributions are still truly random.
    – svick
    May 20, 2014 at 12:06

What you're looking for is Fitness proportionate selection.

The way to imagine this is to visualise a game where we spin a wheel to win prizes.
The best prizes have smaller segments (and are less likely to be won) and the rubbish prizes have huge segments (and are more likely to be won).

Here's how I would implement this:

Assign (or calculate) the likelihood of each of your items occurring.

1 60%
2 30%
3 4%
4 3%
5 2%
6 1%

We'll turn these into decimals because this will be easier to work with now. The only important thing is that these values add up to one:

1 60%   .6
2 30%   .3
3 4%    .04
4 3%    .03
5 2%    .02
6 1%    .01

Next calculate the cumulative values for each item in your array:

1 60%   .6
2 30%   .9
3 4%    .94
4 3%    .97
5 2%    .99
6 1%    1.00

Then generate a random number between 0 and 1.

Find the position in your cumulative array where this random number would be inserted. The value at this position is the value that has been selected.

For example - if we generate 0.5 that would be inserted at the first element of your array, so we select 1.
If we generate 0.7 that would fit into the next position so we select 2, and so on.


Another approach could be to apply some function to the random numbers. This works nicely for floating point random numbers, which usually come between 0 and 1 subjected to functions like square(x) or square_root(x), which distort the distribution while staying within the original interval.

Not the answer you're looking for? Browse other questions tagged or ask your own question.