Rolling Any-Sided Die: Probability and Randomization

  • Context: Undergrad 
  • Thread starter Thread starter ComputerGeek
  • Start date Start date
  • Tags Tags
    Probability Rolling
Click For Summary
SUMMARY

The discussion centers on the construction of a program to simulate rolling a die of any size, emphasizing the importance of generating random numbers correctly. It is established that using the modulus operator with a random number does not yield a true representation of a six-sided die due to potential zero results; thus, an adjustment of adding one is necessary. Participants debate the differences between real-world dice rolls and computer-generated outcomes, with some asserting that human rolls exhibit patterns that may not be present in random number generation. The conversation highlights the need for proper randomization techniques and the significance of understanding the limitations of random number generators in programming.

PREREQUISITES
  • Understanding of random number generation algorithms
  • Familiarity with programming languages, specifically Perl and its rand function
  • Knowledge of probability theory, particularly regarding dice rolls
  • Experience with statistical analysis and data collection methods
NEXT STEPS
  • Research the implementation of random number generators in Perl, focusing on the rand function and seeding techniques
  • Explore probability distributions and their applications in simulating dice rolls
  • Investigate the effects of sample size on perceived randomness in experimental data
  • Learn about statistical analysis methods to evaluate the randomness of generated numbers
USEFUL FOR

Game developers, statisticians, and programmers interested in simulating random events, particularly in gaming applications like Dungeons & Dragons.

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?
 
Physics 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

  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 6 ·
Replies
6
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 16 ·
Replies
16
Views
4K
  • · Replies 1 ·
Replies
1
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 14 ·
Replies
14
Views
2K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 25 ·
Replies
25
Views
2K
Replies
2
Views
2K