# Dice question

1. Dec 19, 2005

### ComputerGeek

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?

2. Dec 19, 2005

### MSI

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 (:

3. Dec 19, 2005

### ComputerGeek

well.. true, but it is still 1/6 chance of getting each member of the set as with a die roll. correct? Im pretty sure it is, (as long as I pic my upper limit well I suppose)

4. Dec 19, 2005

### shmoe

You need each residue class to have the same probability of being selected, that's all.

5. Dec 19, 2005

### Tide

That will work just fine because you have 6 equally likely outcomes (0, 1, 2, 3, 4 and 5).

6. Dec 19, 2005

### ComputerGeek

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?

7. Dec 19, 2005

### NateTG

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.

8. Dec 19, 2005

### ComputerGeek

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 .

Good randomness is proper for somethings.. not role playing though :-D

9. Dec 19, 2005

### shmoe

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. Dec 19, 2005

### DaveC426913

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. Dec 19, 2005

### ComputerGeek

oh, well you have to include the "roll it really eccentrically" kind of rolls.

12. Dec 19, 2005

### shmoe

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. Dec 19, 2005

### DaveC426913

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. Dec 19, 2005

### Tide

The operative word is "seems." Let's see some data! :)

15. Dec 20, 2005

### DaveC426913

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.

16. Dec 20, 2005

### tony873004

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. Dec 20, 2005

### DaveC426913

Cool!

BTW, this page http://www.angio.net/pi/piquery" [Broken] 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: May 2, 2017
18. Dec 21, 2005

### robert Ihnot

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. Dec 21, 2005

### tony873004

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. Dec 22, 2005

### ComputerGeek

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.