Before answering "What are the odds of this happening?" It might make more sense to ask "In a perfect world, how soon could this happen?" (and could it happen at all?)
In a class of 39 students, is it possible for student A to meet all 38 of their classmates if the class is in random groups of 3 every class and the class meets 40 times? Definitely!
Let's consider a best-case scenario. My scratch work associated with this process is shown in the image to the left.
On the first day, Student A meets 2 new students, leaving 36 students unmet
On the second day, Student A meets 2 more new students, leaving 34 students unmet
We can see that with each new day, 2 fewer students are left to meet in the class. So, the number of students left to meet can be modeled by the expression: -2x + 38. So, when will the number of students left to meet be zero?
-2x+38 = 0 is true when x = 19
So, on the 19th day, in a perfect scenario of working with two new students every class, the student would have met everyone in the class!
I realized after doing this that there is an easier method: If student A is meeting 2 new people every day, how long does it take to meet 38 people? Well, that's just 38/9 = 19.
Now, let's keep going and explore the odds of this happening.
Above, we considered the ideal scenario and learned that if this scenario occurs, it would take 19 days for the student to meet everyone in the class.
Before diving into the true odds of meeting everyone in the class, let's consider the odds of this perfect scenario. What are the odds that the student is grouped with new people every time until they've met everyone in the class?
The video to the left shows how I answered this question, and my process is also described below.
Let's think about this day by day:
On this first day, there is a 100% chance that both of the students will be new students.
On the second day, there is a 36/38 chance that one of his group members will be new. Assuming we get that new student in our group, there's now a 35/37 chance that the other group member will also be new. This gives a total chance of (36*35)/(38*37) or approximately 89.69%
On the third day, there are now 34 sudents we haven't met yet. So, there is a 34/38 chance of group member 1 being new. After that person joins our group, there is a 33/37 chance that the second member of the group is new. So, there is a 34*33/(37*38) chance or approximately 79.80% chance that both group members are new on the third day IF I already know I had new group members on all the previous days. If I want to know the odds that I had new group members on the second day AND on the third day, I need to multiply these odds: (36*35*34*33)/(38*37*38*37) or approximately 71.51%
I notice that there is a pattern on the numerator and denominator. Once I am on day 19, I will have (36*37*35*....*1)/((38^18)*(37^18)) or approximately 8.0686221255601510549174225377663155171506095311241430120570 × 10^-16
Notice the "times 10 to the negative 16" that means this answer is really 0.0000000000000008068...
So a VERY small chance this ideal scenario happens.
Sometimes, the probability work alone isn't very convincing, and seeing the entire sample space and considering the specific scenario can be more convincing. So, I created a spreadsheet to visualize what was happening and was able to confirm for myself the numbers I got in my calculations above.
Calculating theoretical probability in complex conditional situations, get complicated really fast!
The scratch work to the left was my attempt at using a Tree Diagram to map the odds of meeting different numbers of people over time. On the first day I am guaranteed to meet 2 people, on the next day I might meet two more (for a total of 4), one more (for a total of 3) or no more (for a total of still 2 people met). I noted how many groups fit into each of those scenarios. This got complicated quickly with 9 branches on day 3.
Still, I thought I had found a pattern with how I was doing my calculations and tried to switch to a spreadsheet to continue further. Check out the tabs "Real Scenario Attempt 1" and "Real Scenario Attempt 2" in my spreadsheet if you'd like to try to make sense of what I was trying to do; or perhaps it will inspire you to make your own, better spreadsheet to calculate the theoretical probability.
After several hours of trying and trying again, and then trying for a couple more hours the next day, I decided to call it quits on this method, and instead use experimental probability.
Horizontal axis shows number of other students met after 40 days, vertical axis is percent of simulations run
Experimental probability uses simulations to calculate the odds of something occurring. The more simulations that are run, the closer the experimental probability gets to the theoretical probability.
I created a python script to simulate this situation. If you enjoy coding or want to learn, here is the script I wrote: groupSim.py
I tried to use good comments so that it could be understood by others.
After writing my code, I told someone about it and they wanted to see if they could write a more efficient script, and based on the run times of us both trying to run 1,000,000 simulations, they were successful at creating a more efficient script. They also added a fun text-based bar chart creator at the end of their. Check out their code here: groupSim2.py
I used my code to run simulations and put the results into this spreadsheet.
To hear me explain how to read and interpret this spreadsheet, watch this video.
Based on my simulations, there is roughly a 0.38% chance that Student A would meet all 38 other students in the class. However, it is quite likely Student A would meet at least 25 other students.
What are the chances we get put into the same group every time?
On day 1 I will meet two people
On day 2, there is a 2/38 chance one of them is in my group and a 1/37 chance the other one also gets put in my group
These odds stay the same on every day up to day 40.
So, by day 40 the odds will be (2^39 * 1^39)/(38^39 * 37^39)
This gives a probability of 9.305555940323804725063804708404411511328349416749115170488 × 10^-112
Or 0.[111 zeroes]9305...
Incredibly unlikely!