PDA

View Full Version : Loaded Random number generation



Gnoman
2015-08-16, 12:07 PM
short version: I need a quick and easy way to generate a value between .5 and 1.5 (50% and 150%), with the results weighted so that the most common value will be 1 (100%) and descend in a nice curve much like that produced by 2d6. Ideally, this will generate a fairly granular (in other words, there should not be less than 5% difference between possible results, and 1% is the ideal) spread and be done with no tables and with a single die roll (as I'm using electronic dice, this can be fairly complex).



For a game I'm running on another forum, every unit in the game has a specific point value. What I want to do is generate scenarios where the attacking faction has a possibility of being either outmatched significantly or having a significant advantage, but is most likely to be right around the same score.


Basically, each side will deploy units to "sectors", and each game turn I will generate a combat scenario from the forces available to each side by picking first the mission type, then the attacking force (from ships in the area) and finally the defending force. The defending force will be generated by rolling the percentage (between half and 1.5x the attacking force) and units from the area will be selected to match that as closely as possible following other restrictions.

Razanir
2015-08-16, 12:18 PM
The easiest way: .5+(2d6-2)/11

I'll see what else I can think up.

Three ways to get 50-150:

2d51+48 (http://anydice.com/program/6661)

10d11+40 (http://anydice.com/program/6663)

20d6+30 (http://anydice.com/program/6664)

Chronos
2015-08-16, 04:14 PM
(in other words, there should not be less than 5% difference between possible results, and 1% is the ideal)
You want not less than 5%, and ideally 1%? I think you might want to restate something there.

And how tightly do you want the results clustered around 1? Do you just want a triangular distribution like 2d6, or something with a bell curve?

Assuming that you want a triangular distribution, then you want (2dn + n - 3)/ (2n-2) , where n is any suitably large number. For instance, if you use n = 51, then you recover Razanir's (2d51 + 48)/100 . But you could also use n = 100, or n = 1000, or any other value you choose.

Razanir
2015-08-16, 05:20 PM
Assuming that you want a triangular distribution, then you want (2dn + n - 3)/ (2n-2) , where n is any suitably large number. For instance, if you use n = 51, then you recover Razanir's (2d51 + 48)/100 . But you could also use n = 100, or n = 1000, or any other value you choose.

My (2d51+48)/100 is special, because it's also in increments of exactly 1%.

Rockphed
2015-08-16, 05:35 PM
There are 2 ways to change the shape of your curve. First, you can make the steps between points vary in size (e.g. 2d6 has 11 points, 2d51 has 101). Secondly, you can change the curvature of your distribution. 2d6 has a triangular distribution, as will any set of 2 dice. If you want something more normal, you will need to increase the number of dice. I suggest (100d2 - 50)%. Like (2d51-48)/100, it has 1% granularity. Like a normal distribution, it has a very heavy weight around 100%, with the ends being vanishingly small. Getting a 50% is a 1 in 2^100th chance. Which works out to about 1 in 1000,000,000,000,000,000,000,000,000,000. That might not be what you are looking for. At any rate, if you want it more heavily weighted to the center, increase the number of dice. If you want it to have a specific granularity, either increase the number of dice or increase the size of the dice.

factotum
2015-08-17, 02:33 AM
Is this on a computer? If so, you could generate any arbitrary random curve you like by just defining how likely each possibility is in an array, then picking the one that matches.

Simple example: set up an array with 6 entries, values 0.1, 0.2, 0.5, 0.8, 0.9, 1.0. Then pick a random number between 0 and 1 and loop through until you find the first value in the array which is higher than that number; the random numbr you return is the index into the array. The above would give you random numbers 1-6, but with 3 and 4 being 3 times more likely to be picked than the others.

Gnoman
2015-08-17, 07:10 AM
You want not less than 5%, and ideally 1%? I think you might want to restate something there.

And how tightly do you want the results clustered around 1? Do you just want a triangular distribution like 2d6, or something with a bell curve?

Assuming that you want a triangular distribution, then you want (2dn + n - 3)/ (2n-2) , where n is any suitably large number. For instance, if you use n = 51, then you recover Razanir's (2d51 + 48)/100 . But you could also use n = 100, or n = 1000, or any other value you choose.

Yes, I worded that wrong. I want it to be between 1% and 5% increments, and (2d51+48)/100 looks to be just about perfect.