1. ## Dice Theoretical Probability

Hi,

How can I calculate the theoretical probability of the number of times I would have to roll a 6 sided dice until I got at least 1 of every number?

I can't figure this out!

Thanks!

2. Originally Posted by colourfulclock
Hi,

How can I calculate the theoretical probability of the number of times I would have to roll a 6 sided dice until I got at least 1 of every number?

I can't figure this out!

Thanks!
You can't.

What you can calculate is either:

1. The expected number of rolls; or

2. The number of rolls such that the probability exceeds a specified value eg. 0.999.

3. Originally Posted by colourfulclock
Hi,

How can I calculate the theoretical probability of the number of times I would have to roll a 6 sided dice until I got at least 1 of every number?

I can't figure this out!

Thanks!
My reading of this question is calculate p(n) the probability that exactly n rolls are needed to have at least one of each possible result 1,2,3,4,5,6.

You can start by assuming that the last roll to achieve a complete set is a 1. Then for the n-1 earlier rolls we have a binomial experiment where we want to know the probability of n-1 successes at a probability of 1/(n-1), and for the n-th roll we have a probability of success (getting a 1) of 1/6.

CB

4. Wrote short simulation program; 5 runs @ 10 million tries each:
147,011,358
147,033,575
147,000,132
146,994,434
147,035,012
So looks like slightly over 14.7 rolls

If wrong, can anyone tell me what's wrong with my program:

100 set up array A(6)
110 for g = 1 to 10000000
120 array A = 0
130 r = 1 'r = rolls
140 k = random number 1 to 6
150 A(k) = 1
160 if array A = 6 then goto 180
170 r = r + 1:goto 140
180 t = t + r
190 next g
200 print t

5. Originally Posted by Wilmer
Wrote short simulation program; 5 runs @ 10 million tries each:
147,011,358
147,033,575
147,000,132
146,994,434
147,035,012
So looks like slightly over 14.7 rolls

If wrong, can anyone tell me what's wrong with my program:

100 set up array A(6)
110 for g = 1 to 10000000
120 array A = 0
130 r = 1 'r = rolls
140 k = random number 1 to 6
150 A(k) = 1
160 if array A = 6 then goto 180
170 r = r + 1:goto 140
180 t = t + r
190 next g
200 print t
Well to start with this does not calculate the probability asked for, also what does the line

160 if array A = 6 then goto 180

do?

CB

6. Originally Posted by colourfulclock
Hi,

How can I calculate the theoretical probability of the number of times I would have to roll a 6 sided dice until I got at least 1 of every number?

I can't figure this out!

Thanks!
This is the "Coupon Collector's Problem". See

Coupon collector's problem - Wikipedia, the free encyclopedia

7. Originally Posted by Wilmer
Wrote short simulation program; 5 runs @ 10 million tries each:
147,011,358
147,033,575
147,000,132
146,994,434
147,035,012
So looks like slightly over 14.7 rolls

If wrong, can anyone tell me what's wrong with my program:

100 set up array A(6)
110 for g = 1 to 10000000
120 array A = 0
130 r = 1 'r = rolls
140 k = random number 1 to 6
150 A(k) = 1
160 if array A = 6 then goto 180
170 r = r + 1:goto 140
180 t = t + r
190 next g
200 print t
The simulation results look OK.

CB

8. Originally Posted by CaptainBlack
also what does the line
160 if array A = 6 then goto 180 do?
Thanks CB, you're telling me I misunderstood; I took the problem to mean:
after how many rolls will each of 1 to 6 appear at least once; example:
3,5,3,1,2,6,1,5,6,6,2,1,3,5,4: 15 rolls

After a number (1 to 6) is picked, program "flags" the corresponding array
number with "1"; like, after picking the 3 at start, program makes A(3) = 1.
at this point, all array locations were equal to 1, so array totalled 6.
So this session was completed, and program goes to line 180 in order
to update the total rolls so far.

Can you tell me what I'm missing? Thanks.

9. Originally Posted by Wilmer
Thanks CB, you're telling me I misunderstood; I took the problem to mean:
after how many rolls will each of 1 to 6 appear at least once; example:
3,5,3,1,2,6,1,5,6,6,2,1,3,5,4: 15 rolls

After a number (1 to 6) is picked, program "flags" the corresponding array
number with "1"; like, after picking the 3 at start, program makes A(3) = 1.
at this point, all array locations were equal to 1, so array totalled 6.
So this session was completed, and program goes to line 180 in order
to update the total rolls so far.

Can you tell me what I'm missing? Thanks.
Nothing, if you understand what that line means.

Though I will say this: the syntax of the language is unacceptable in that it makes no distinction between the assignment operator and the logical equality operator, and the "array" qualifier seems to be overused and the function notation is counter-intuitive and non-standard. Also profligate use of GOTOs in modern code is deprecated.

CB

10. Originally Posted by CaptainBlack
Though I will say this: the syntax of the language is unacceptable in that it makes no distinction between the assignment operator and the logical equality operator, and the "array" qualifier seems to be overused and the function notation is counter-intuitive and non-standard. Also profligate use of GOTOs in modern code is deprecated.
CB
Agree 100%. I was simply using "English": too lazy to actually type the actual code.
Plus I use UBasic: why type code that would be "strange" to anyone not exposed to UBasic...

11. Originally Posted by Wilmer
Agree 100%. I was simply using "English": too lazy to actually type the actual code.
Plus I use UBasic: why type code that would be "strange" to anyone not exposed to UBasic...
If you are using pseudo-code you should get rid of line numbers, it should be readable without being confused with real code:

Code:
set Nreplications=10000            //number of replications of the experiment
set array A[1..6] to zero vector   //array of flags to indicate if a face has come up in an experiment
set counter=0                      //counts number of throws in an experiment

for idx=1 to Nreplications
for throw=1 to infinity
set A to zero vector
set k to UniformRand on {1,2,..6}
set A[k] to 1

if (sum of A[k], k=1,..6) is equal to 6
set total to total+throw
break out of throw loop
end if
end for
end for
output total/Nreplications

12. Hokay...