An N N -sided die

Jorge has an N N -sided fair die and wonders how many times he would need to roll it until he has rolled all the numbers from 1 1 to N N (in any order).

He does a quick calculation and discovers that the expected value for the number of rolls is 91 when rounding to the nearest integer.

How many sides does his die have?

Clarification: One distinct number from 1 1 to N N is printed on each face of the die.


Image credit: ravnerdwars.info

Other Expected Value Quizzes


The answer is 24.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Geoff Pilling
May 21, 2016

This is an example of the famous "Coupon Collector's Problem" .

The expectation value for "collecting" N N different objects (or in this case numbers on a die) is given by:

E ( N ) = N ( 1 / 1 + 1 / 2 + . . . + 1 / N ) E(N) = N(1/1 + 1/2 + ... + 1/N)

This gives E ( 24 ) = 90.62 E(\boxed{24}) = 90.62 . ( 91 91 when rounded to the nearest integer)

Good luck building a dice with 24 faces

Bee La Salle - 4 years, 7 months ago

Log in to reply

Hahaha... Yup!

Geoff Pilling - 4 years, 7 months ago

What is a good way to find the value of such an N?

Agnishom Chattopadhyay - 4 years, 11 months ago

Log in to reply

The series is an increasing series you can use binary search on paper to get the quickest answer I guess..

Shubham Sharma - 4 years, 11 months ago

Log in to reply

What bounds do I use for the binary search?

Agnishom Chattopadhyay - 4 years, 11 months ago

Log in to reply

@Agnishom Chattopadhyay @Agnishom Chattopadhyay {1 , 30 }, well you can even guess the bound just by checking the value of the function at every 10 integers! I made a code that is why It was very simple for me .

But this surely does reduce the number of comparisons but I feel like sometimes we too never make a linear search we always increase by some constant C. But Binary search is algorithmically fastest though :) .

Shubham Sharma - 4 years, 10 months ago

Log in to reply

@Shubham Sharma binary search is costly as you have to iterate 1 to n for each possible n. my idea is result(1) = 1 result(k) = result(k-1)/(k-1)*k + 1

just try each k increasing from 1 until you find your solution.

Md Arifuzzaman Arif - 2 years, 8 months ago

you can better write code .

sanket Meshram - 2 years, 2 months ago

Guess and check problem? I used the n * log n bound and tried 23, 25, and 27 ...

Elliot Liu - 2 years, 2 months ago
Shivam Jalotra
Apr 9, 2020

Here is the code so that you can simulate the "coupon collector problem" using monte-Carlo simulations.

EXPLANATION :
1. This code gets a random objects from the set S == {1, 2, 3 ... . totaldistinctobjects }.
2. And then do the above line numberofsimulations times.
3. For each unique value that we got we add the value to a set s.
4. Remember a set contains only unique keys.
5. If the number of unique elements in the set is equal to totaldistinctobjects then we found a way to reach the state of getting N unique elements.
6. Finally lets say that X is a random variable and X defines the number of ways to get all N unique elements.
7. Now I define this similar to the number of coin tosses required to get the first head problem, like this : Number of simulations needed to find a way to get all N unique elements. So E[X] = 1/(probability of getting all N unique elements) .



Results

E[X] numberofdistinctobjects
85.9401856308 23
90.8100254268 24
95.4380606986 25
100.290843446 26
105.418511491 27

CODE STARTS

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
def simulate(numberofsimulations, totaldistinctobjects):
    total = 0
    found = 0
    s = set()
    for i in range(numberofsimulations):
        output = random.randint(1, totaldistinctobjects)
        s.add(output)
        total += 1
        if len(list(s)) == totaldistinctobjects:
            found += 1
            # clear the set
            s.clear()
   # return the expected value.  
return float(total)/float(found) 

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...