Rolling Any-Sided Die: Probability and Randomization

AI Thread Summary
The discussion centers on the challenges of simulating die rolls through random number generation, particularly for a program designed to mimic human rolling for games like Dungeons & Dragons. Participants debate whether using a modulus operation on random numbers accurately reflects the probabilities of rolling a six-sided die, noting that adjustments must be made to account for the range of generated numbers. There is a recurring theme regarding the perceived consistency of real-world rolls versus computer-generated rolls, with some arguing that human rolling can exhibit patterns that are not truly random. The conversation also touches on the importance of statistical analysis to validate observations about rolling outcomes, emphasizing the need for empirical data to support claims about randomness. Ultimately, the complexities of achieving "less perfect" randomness in simulations are highlighted, questioning the feasibility of replicating human imperfections in rolling.
ComputerGeek
Messages
383
Reaction score
0
I am constructing a program that will roll a die of any size (up to what ever limit the computer system can use for random numbers)

is generating a random number than then looking at it mod 6 probabilistically the same as rolling a 6 sided die?
 
Mathematics news on Phys.org
no , because some times you will get zero as a result for mod , and you will never get 6 (:

so you must add 1 to the final answer (:
 
well.. true, but it is still 1/6 chance of getting each member of the set as with a die roll. correct? I am pretty sure it is, (as long as I pic my upper limit well I suppose)
 
ComputerGeek said:
well.. true, but it is still 1/6 chance of getting each member of the set as with a die roll. correct? I am pretty sure it is, (as long as I pic my upper limit well I suppose)

You need each residue class to have the same probability of being selected, that's all.
 
That will work just fine because you have 6 equally likely outcomes (0, 1, 2, 3, 4 and 5).
 
you know what I am finding though, real world roles tend to produce more consistent results than computer generated roles.

some one who roles a 5 seems to have a better chance of re-roling a 4,5,or 6 than a 1, 2, or 3 (depending on the rolling method).

what do you think?
 
ComputerGeek said:
you know what I am finding though, real world roles tend to produce more consistent results than computer generated roles.
some one who roles a 5 seems to have a better chance of re-roling a 4,5,or 6 than a 1, 2, or 3 (depending on the rolling method).
what do you think?

There are, of course, limitations on how well people roll. If people roll well, say by using a dicing cup and shaking it for a while, then you're likely to get reasonable results. Throwing by hand isn't nearly so good.

As a note, random number generators typically return results that are in the range [0,2^{n-1} which is obviously not divisible by six. If you *really care* you have to account for that.
 
well, the rand function in perl generates a floating point number. but I changed my algorithm to just generate a random number of the size limits I am looking for rather than moding a large random number.

I am looking to make a program that is in fact less perfect in order to emulate human rolling. It is to replace game dice for D and D :-P.

Good randomness is proper for somethings.. not role playing though :-D
 
ComputerGeek said:
you know what I am finding though, real world roles tend to produce more consistent results than computer generated roles.

some one who roles a 5 seems to have a better chance of re-roling a 4,5,or 6 than a 1, 2, or 3 (depending on the rolling method).

what do you think?

I would think your dice are unbalanced or they aren't really "rolling" the dice or you don't have a very large sample size and/or are just going on anecdotal evidence.

Dice don't remember the last thing they rolled (barring unusual damage to the die).
 
  • #10
ComputerGeek said:
well, the rand function in perl generates a floating point number. but I changed my algorithm to just generate a random number of the size limits I am looking for rather than moding a large random number.
I am looking to make a program that is in fact less perfect in order to emulate human rolling. It is to replace game dice for D and D :-P.
Good randomness is proper for somethings.. not role playing though :-D
I can't imagine how you might do/find such a thing, even in theory.

"less than perfect" is meaningless unles you can determine the causes and effects.

In what way do humans roll imperfectly? Higher than average? Lower? Excess repeats?

This seems a bizarre thing to try to attain. Personally, I would bet it is based on a flawed concept. I'll bet the patterns you are perceiving are illusory.
 
  • #11
oh, well you have to include the "roll it really eccentrically" kind of rolls.
 
  • #12
ComputerGeek said:
oh, well you have to include the "roll it really eccentrically" kind of rolls.

What is a "roll it really eccentrically" kind of roll? The kind where the person is trying to cheat? You will have to deliberately work at it to get rolls that are non-random (assuming decently "fair" dice).
 
  • #13
shmoe said:
What is a "roll it really eccentrically" kind of roll? The kind where the person is trying to cheat? You will have to deliberately work at it to get rolls that are non-random (assuming decently "fair" dice).
I'm with you. I dispute the suggested ability for a player to alter the randomness of the dice toss (except perhaps with a seriously blatant attempt to drop a single die at a time without rolling them).

And even if I concede on that, I also dispute the ability to then quantify cause and effect of that in a way that is of any use in a program.

I think my first requirement for even the most perfunctory look at this would require an explanation of what kind of deviation from randomness you expect to see.

Are we talking a repitition of rolls?


(Hm. 'dispute', 'concede','require'. Don't mean to sound so condescending...)
 
  • #14
ComputerGeek said:
you know what I am finding though, real world roles tend to produce more consistent results than computer generated roles.
some one who roles a 5 seems to have a better chance of re-roling a 4,5,or 6 than a 1, 2, or 3 (depending on the rolling method).
what do you think?

The operative word is "seems." Let's see some data! :)
 
  • #15
ComputerGeek said:
you know what I am finding though, real world roles tend to produce more consistent results than computer generated roles.
some one who roles a 5 seems to have a better chance of re-roling a 4,5,or 6 than a 1, 2, or 3 (depending on the rolling method).
what do you think?
That's a flaw in your observation techniques, not in the actual phenomenon.

It's the same principal as "more babies are born under a full Moon" and "more crimes happen under a Full Moon".

It's perceptual. Humans make patterns where there are none. How many times have you (or anyone you know) heard of the birth of a baby and said "Say, that's the third baby this year born under a waning cresecent Moon!"

Your brain is noticing the closness between the "5" and the subequent "4", "5" or "6". Your brain doesn't bother noticing a "5" followed by a "1" "2" or "3".

Give us numbers. Roll (or have your friends roll) a die a hundred times. Post the data. We'll analyze it together.



P.S. As one "roll"-player to another ... "roll" is dice. "role" is people. :wink:
 
  • #16
Don't forget to seed the random number generator, or you may see the same patterns over and over again. At least that's how it works in Visual Basic. I'm not sure about Perl.

Just because you look at the data and it seems non-random doesn't mean that it is non-random. Random groups of numbers should have repeats and lots of other coincidences embedded in it. There's a web page that gives the value of pi to 1 million digits. I did a ctrl+F and found my phone number.
 
  • #17
tony873004 said:
There's a web page that gives the value of pi to 1 million digits. I did a ctrl+F and found my phone number.

Cool!

BTW, this page http://www.angio.net/pi/piquery" will do the search for you, and it searches up to 200 million digits.

I am at 7,812,036 and 36,412,751 - (home and cell phone respectively)*. I had to use only 7 digits. My 10-digit numbers weren't to be found**.

And now, with a little effort, you know my phone numbers... something else that page does...


**And there's a handy chart to show why a 10-digit number will likely not be found:
Number Length Chance of Finding
-------------- -----------------
1-5...100%
6.....Nearly 100%
7.....99.995%
8.....63%
9.....9.5%
10...0.995%%
11...0.09995%
 
Last edited by a moderator:
  • #18
One thing I have noticed in dice is how frequently a number is followed by the same, say in the roll: 2,4,5,5.

One might expect that the chance of getting a 5 twice is 1/36, but that is not the case above. The fact is that the chance that X is follow by X is one chance in 6.
 
  • #19
robert Ihnot said:
One thing I have noticed in dice is how frequently a number is followed by the same, say in the roll: 2,4,5,5.
One might expect that the chance of getting a 5 twice is 1/36, but that is not the case above. The fact is that the chance that X is follow by X is one chance in 6.

It's actually the same thing. The chance of getting a 5 twice is 1/36. X followed by X is one in six, but X doesn't have to be 5. It could be 1,2,3,4,5 or 6.

So pairs should 1/6, and pairs of 5's should be 1/36.
 
  • #20
in perl 5 rand is already seeded. if you want it to be compatible with older perl versions, then you have yo use srand first to seed it and then you can use rand.
 

Similar threads

Back
Top