Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In a football or soccer game, you have 22 players, from both teams, in the field

ID: 3701540 • Letter: I

Question

In a football or soccer game, you have 22 players, from both teams, in the field. What is the probability of having any two players with the same birthday? (just assume 365 days a year and don’t have to do the exact calendar month and day, use the day number from 1 to 365)

Please use two approaches to solve the problem.

One, find the closed form mathematical solution by probability theory. Show your derivation/proof.

Two, write a program to simulate the birthday for each player per iteration and then tabulate the results in terms of occurrence of same birthdays over number of iterations. Do cases of 10, 50, 100 and 500 iterations, or more. The larger the number of iterations (samples), the closer the result is to the theoretical probability. What do you call this theory, or law? ( I’ve already given two-third of the name in the last sentence)

Hints:

For approach #1, you are free to do your research and study from the web, or any source, but do your own work.

For approach #2, the problem statement implies you need to do a match-search after generating the birthdays; and then do the booking keeping of the results for all iterations. Good opportunity to apply "arrays". And, before running it using srand() and rand() to generate the birthdays, put your ‘fixed’ data there to verify the search, book keeping and data output algorithms first.

PLEASE READ CAREFULLY THE QUESTION. THANK YOU!!

Explanation / Answer

ScreenShot

----------------------------------------------------------------------------------------------------------------------

Program

//Header Files
#include<iostream>
#include<cstdlib>
#include<ctime>
using namespace std;
//main method
int main()
{
   //variable declaration
   int playerCount = 22, count = 0, birthDays[22];
       double p=0;//probability
  
   //Number of trial for 10
   for (int trial = 0; trial < 10; trial++)
   {
       //Randomly generate up to 22 players birthdays
       for (int i = 0; i < playerCount; i++)
       {
           //generate random birth day betwee 1-365
           birthDays[i] = (rand() % 365) + 1;

           //this loop check if some birthday is equal to the one just generated
           for (int j = 0; j < i; j++) {
               if (birthDays[j] == birthDays[i]) {
                   count = count + 1;
               }
           }
       }
   }
   //calculate probability
       p = count / 10;
       //display probability
       cout << "The probability of a shared birthday in a team of 22(at trial 10) is " << p << endl;
    return 0;
}


--------------------------------------------------------------------------------------------------------------------------

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote