Weighted Random Numbers?

I would like to generate random numbers, from 1 to 10, based on the following weights:

1 → 3%
2 → 18%
3 → 22%
4 → 16%
5 → 11%
6 → 9%
7–> 7%
8 → 6%
9 → 4%
10 → 4%

(i.e.: 1 would come up 3% of the time, 2 would come up 18% of the time, etc.)

I’m not sure how to do this. Generating the random numbers is no problem but I don’t know how to apply the weighting to the generation process.

Background on the project at hand: I’m a graphics artist and I’m sometimes asked to create various designs for clients. I usually don’t have the clients text when I begin my design process. I would like to create “greeking” text to fill out my layouts with. The above weights represent the frequency that words of a given character count come up in the “typical” written word. I can generate sentences with a random number of “words” and paragraphs with a random number of sentences (both of those are simple random number generations between given ranges), but I haven’t figured out this part of the process yet.

Thanks in Advance,
Brad Bumgarner, CTA

You build a 100-item list containing three 1s, eighteen 2s, etc., then use ‘some item of theList’ to grab one of them at random. Or, in your particular case, just fill the list with the words themselves.

I like it. Very “do-able.” :smiley: I knew there was an easy answer, I just couldn’t come up with it.

Brad Bumgarner, CTA



Thanks Mike, I’ve had that file off and on for over 20 years. Just thought it’d be a fun project to work on for myself.

Thanks again,
Brad Bumgarner, CTA