PDA

View Full Version : Calling all math nerds: How to Determine Arbitrary Random Numbers?



subject42
2010-09-28, 02:17 PM
Assuming that I want to represent a random number at the table that sits between 1 and an arbitrary upper bound, inclusively, what is the best way to do it that doesn't involve a computer or calculator?

I don't think that dice will cut it, because I can't think of any combination of dice that could be used to represent 1 in 37 or 1 in 19 chance.

Does anyone have any good ideas?

Urpriest
2010-09-28, 02:21 PM
Cards are a decent way. So it rolling a d% or several and just re-rolling when you get too high.

Duke of URL
2010-09-28, 02:26 PM
The simplest way would, of course, be a computer.

For low enough numbers (like 19), roll the next highest-sized die, ignoring out-of-range results. (E.g., roll 1d20, ignoring any 20s.)

Failing that, I would roll Nd10, with N being log10 of your target number, rounded up; reading the dice similarly to percentile dice. This is the same as above, really, just using an arbitrary decimal bound instead of normal d%. Take 10N divided by your target number, rounded down. Divide your die roll result by this to get your random value. If the result is out of range, re-roll.

Example:

Target = 37
N = 2
102 / 37 = 2

{table]Die Roll|Random Result
01 | 1
14 | 7
50 | 25
74 | 37
75+ | re-roll, ignoring results > 74[/table]

Fax Celestis
2010-09-28, 02:27 PM
I don't think that dice will cut it, because I can't think of any combination of dice that could be used to represent 1 in 37 or 1 in 19 chance.

Does anyone have any good ideas?

1/37: 1d150, reroll 149 and 150.
1/19: 1d100, reroll 96, 97, 98, 99, and 100.

Ernir
2010-09-28, 02:28 PM
Numbered cards, say from 1-100 (or however many you need). Keep them ordered, and when one of those stupid 1-in-prime-number-above-3 chances comes up, take out as many as you need, shuffle, and draw.

Have someone re-order them while they are waiting their turn in combat. :smalltongue:

GoodbyeSoberDay
2010-09-28, 02:28 PM
You need geometry and dice manufacturing nerds, not math nerds. That said, with the standard D&D dice (multiple d4s, d6s, d8s, d10s + percentiles, d12s and d20s), I usually do the following if I need to roll XY, where X is the tens digit and Y is the ones digit.

I take a bright colored dA, where A is as close to X as possible while A>X, and use it to represent my tens digit. If the dA rolls above X, I re-roll it.

Then I take a different bright-colored dB, where B is as close to Y as possible while B>Y, and use it to represent my ones digit. If the dB rolls above Y, I re-roll it.

ericgrau
2010-09-28, 02:33 PM
Assuming that I want to represent a random number at the table that sits between 1 and an arbitrary upper bound, inclusively, what is the best way to do it that doesn't involve a computer or calculator?

I don't think that dice will cut it, because I can't think of any combination of dice that could be used to represent 1 in 37 or 1 in 19 chance.

Does anyone have any good ideas?

1 in 37: 1d4 for first digit, 4 => 0. 1d10 for second digit. Re-roll on 38 and 39 (5% chance of reroll)
1 in 19: 1d20, re-roll 20. 5% chance of re-roll.
General: It may help to get dice numbered starting at 0. Round up whatever you want, pick the right dice (usually including 1 or more d10s), then re-roll if the answer is invalid.

shadow_archmagi
2010-09-28, 02:37 PM
Assuming that I want to represent a random number at the table that sits between 1 and an arbitrary upper bound, inclusively, what is the best way to do it that doesn't involve a computer or calculator?

I don't think that dice will cut it, because I can't think of any combination of dice that could be used to represent 1 in 37 or 1 in 19 chance.

Does anyone have any good ideas?

I must ask:

WHY?

dsmiles
2010-09-28, 02:40 PM
I must ask:

WHY?

Why ask why? Try Bud Dry. :smallbiggrin:

Kurald Galain
2010-09-28, 02:43 PM
This is how. (http://rambleon.usebox.net/post/145302856/nine-nine-nine-strip-from-dilbert-oct-25)

subject42
2010-09-28, 02:57 PM
The simplest way would, of course, be a computer.

For low enough numbers (like 19), roll the next highest-sized die, ignoring out-of-range results. (E.g., roll 1d20, ignoring any 20s.)

Failing that, I would roll Nd10, with N being log10 of your target number, rounded up; reading the dice similarly to percentile dice. This is the same as above, really, just using an arbitrary decimal bound instead of normal d%. Take 10N divided by your target number, rounded down. Divide your die roll result by this to get your random value. If the result is out of range, re-roll.

Example:

Target = 37
N = 2
102 / 37 = 2

{table]Die Roll|Random Result
01 | 1
14 | 7
50 | 25
74 | 37
75+ | re-roll, ignoring results > 74[/table]


That will do nicely. Thank you very much.

Skorj
2010-09-28, 02:59 PM
The general method: generate a large random number (say, 5d10 read as a value from 0 to 99999), divide by 37 (or whatever), and use the remainder. That won't give a perfectly even distribution, but then neither do physical dice (cue Lou Zocchi spiel here). Of course, I guess some people would find that hard without a calculator. :smalleek:

In many cases, you can also roll a slightly higher number that's more convenient, and re-roll if the result is too high. E.g., for d37, roll d4 and d10 to get a value from 0 to 39, then reroll if that's out of range.

fusilier
2010-09-28, 03:02 PM
Some wargames use "chits" -- similar to the card idea, but much smaller (typically a die-cut playing piece with a number or code on it describing the result). It actually works pretty well, and is great if you want to generate several random numbers with no duplicates.

Keld Denar
2010-09-28, 03:08 PM
Yea, if a calculator was allowed, I wrote a script for my TI-83 that uses the RANDINT function and a simple while loop to roll XdY dice, where X and Y were any positive interger.

With small odd numbers, its pretty easy. As someone said, just roll the next larger die size and reroll any numbers higher than your target. This is the easiest way to arbitrate Mirror Images. You have a 1 in X chance of hitting the real wizard, where X is the number of images plus one. If there are 7 images, thats a 1 in 8 chance, or 1d8 (hit on a 1). If one image gets popped, you now have 6 images, for a 1 in 7 chance. Thats just 1d8, rerolling 8s, and hitting the wizard on a 1.

Simple simple. You might have to roll a LOT for numbers that are just above the threshold, given standard probability distributions (like rolling a d31 with a percentile), but you'll eventually get there and its about as unbiased as you can physically get unless you fix the dice.

The Mentalist
2010-09-28, 03:09 PM
http://www.random.org/integers/

If you have internet at the table that's useful.

Edit: Re-read and no computers... Drat.

ffone
2010-09-28, 10:29 PM
You desire a random integer from 1 to K.

Choose a larger upper bound N that you can simulate (for example a d20 and a d100 for 2000).

Also figure out the largest multiple of K which is less or equal to N. Call it M.

Draw X from 1 to N. If X<=M, you're done. If X>M, redraw X, and repeat.

valadil
2010-09-28, 10:52 PM
I vote for rolling something above what's needed and rerolling if you go over. It's usually quicker than dividing.

Modular arithmetic can work too, but I've only seen it for low values. It still works higher up. Let's say you need 1d31. Roll 1d100 (or 2d10 as the case may be). If your value is above 31, subtract 31 and check again. Then repeat. You'll have to drop any values above 93 though (since there are 3 complete 31s in 1-100) or your roll will favor 1-7 as they can appear a 4th time each.

I'm still not sure when you'd ever need 1d31 though.

Peregrine
2010-09-28, 11:18 PM
Lots of people are suggesting numbered cards. This would seem to me to be completely missing the part where you need an arbitrary upper bound. Say you need a random number on [1,1000] -- what, you have 1000 cards? And then what about smaller numbers? Draw from the 1000-card deck and discard invalid results? Divide to get close to the valid range?

This has all been suggested for dice, which are much less unwieldly. Duke of URL got the simplest solution(s) in one go. To recap without the reference to logs and exponents: If it fits within a nice easy bound like [1,20], roll the d20 and drop out-of-bound rolls. Otherwise:
Pick the nice round decimal number, like 100 or 1000 or 10000, that fits your desired range inside it.
Roll enough d10s to get that range -- two for 100, three for 1000, and so on.
If your upper bound is more than half the size of this nice round decimal number (e.g. [1,87] simulated with d100), just discard any rolls that are out of range.*
If not -- that is, if your upper bound would go into the nice round decimal number two, or three, or however many times -- divide by that number. [1,31] would go into d100 three times, so we divide by three and discard any result of 32 or 33.
* This might get inconvenient with using d1000 to simulate [1,501], but hey, if you don't want to use a computer, then "inconvenient" is pretty much the name of the game.

EricGrau and ffone pretty much suggested the same thing, with the minor added complication/convenience of not being restricted to round decimal values. A few other people had very similar variations.

(Edited to add: Valadil's method with modular arithmetic, or subtraction instead of division, is probably the easiest of all. Same system, no division.)


1/37: 1d150, reroll 149 and 150.

You have a d150?


You need geometry and dice manufacturing nerds, not math nerds.

Geometry ⊂ maths. :smalltongue: And I'm not sure how dice manufacture would help, except inasmuch as dice manufacturers are geometry/maths nerds.

Fax Celestis
2010-09-29, 08:35 AM
You have a d150?

No, but I can simulate one rather easily with dice.

dsmiles
2010-09-29, 08:39 AM
You have a d150?

I wish I did. But I do have the essential dice: d2, d3, d4, d6, d8, d10, d12, d20, d30, d100 (Zoccihedron, I just like saying Zoccihedron :smallbiggrin:), Doubling Cube, etc.

Zoccihedron.
:smallbiggrin:

Kurald Galain
2010-09-29, 08:48 AM
* This might get inconvenient with using d1000 to simulate [1,501], but hey, if you don't want to use a computer, then "inconvenient" is pretty much the name of the game.
For [1,501], you roll 1d6 and 2d10 to get the three digits. That's less rerolls than 3d10 gives you.

Tyndmyr
2010-09-29, 08:54 AM
Assuming that I want to represent a random number at the table that sits between 1 and an arbitrary upper bound, inclusively, what is the best way to do it that doesn't involve a computer or calculator?

I don't think that dice will cut it, because I can't think of any combination of dice that could be used to represent 1 in 37 or 1 in 19 chance.

Does anyone have any good ideas?

Dice work quite well. Use the next size of die above the desired number(d20 for 1 in 19). Any result above the upper bound is rerolled. Done deal.

subject42
2010-09-29, 08:56 AM
Dice work quite well. Use the next size of die above the desired number(d20 for 1 in 19). Any result above the upper bound is rerolled. Done deal.

That works great until I need a number between 1 and 7,000,000,000,001: that's a lot of potential re-rolls. I think that modulus division is probably going to work best for me, since I have a knack for doing modulus in my head.

Thanks for the ideas, everyone.

Skorj
2010-09-29, 10:30 AM
.... I think that modulus division is probably going to work best for me, since I have a knack for doing modulus in my head.

Thanks for the ideas, everyone.

Well, you did ask for the math geeks. :smallbiggrin:

dsmiles
2010-09-29, 10:35 AM
Have you even considered numbered scraps of paper in a hat?

Tyndmyr
2010-09-29, 11:32 AM
That works great until I need a number between 1 and 7,000,000,000,001: that's a lot of potential re-rolls. I think that modulus division is probably going to work best for me, since I have a knack for doing modulus in my head.

Thanks for the ideas, everyone.

If you need numbers between 1 and 7,000,000,000,001, I would honestly suggest that perhaps your gaming system has too fine-grained detail.

However, if you just want the number, grab some D100s. You'll need six of them and a D10. Roll in order to determine the digits, since you essentially have a D 10,000,000,000,000. About 3/10ths of the time, you'll have to reroll the first die(no need to reroll the rest). No biggie.

dsmiles
2010-09-29, 11:40 AM
If you need numbers between 1 and 7,000,000,000,001, I would honestly suggest that perhaps your gaming system has too fine-grained detail.

Maybe they're playing FATAL? :smalleek:

Snake-Aes
2010-09-29, 11:44 AM
Browsers should run this fine:

javascript: alert(Math.floor(Math.random()*1000000000000));