Question

Need a Python code that will run in spyder Anacoda for the following Mathmatical problem. Q1....

Need a Python code that will run in spyder Anacoda for the following Mathmatical problem.

Q1. Consider an experiment that consists of recording the birthday for each of 20 randomly selected persons. Ignoring leap years, we assume that there are only 365 possible distinct birthdays. Furthermore, we assume that each of the possible sets of birthdays is equi-probable

(1) What is the probability that each person in the 20 has a different birthday?

(2) Find the minimum number of persons such that the probability of two or more people have a same birthday is at least 50%.

(3) Find the minimum number of persons such that the probability of two or more people have a same birthday is at least 95%.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#CODE

""" Q1 Answer
Approach:
   Each person should have a different birthday.
   For 1 person -> probability = 365/365 = 1
   For 2 persons -> probability = 365/365 * (364/365) #As second person has 364 different possiblites excpet one for the first person
   For 3 person -> probability = (365/365) * (364/365) * (363/365)
   ....
"""
n=20
P = 1
for i in range(20):
   P = P * ((365-i)/365)

print("1 Answer:\nThe probability that each person in the 20 has a different birthday : ",P)

def personsRequired(probability):
   """
       We need no.of persons required with the same birthdate with
       given probability. Let's approach this in reverse way that
       are we find people required for 1-probability i.e, people required
       for having different birthdays and then add 1 to them to get two people
       birthday with a given probability.
   """
   negativeProb = 1-probability
   start = 365
   i = 0
   persons = 0
   P = 1
   while(P > negativeProb):
       P = P * ((start-i)/365)
       i+=1
       persons+=1
   return persons

print("2 Answer:\nminimum number of persons such that the probability of two or more people have a same birthday is at least 50% :",personsRequired(0.5))
print("3 Answer:\nminimum number of persons such that the probability of two or more people have a same birthday is at least 95% :",personsRequired(0.95))

#OUTPUT

Add a comment
Know the answer?
Add Answer to:
Need a Python code that will run in spyder Anacoda for the following Mathmatical problem. Q1....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • -11 points BBUnderStat12 1.2.016. O Ask Your T Suppose there are 30 people at a party....

    -11 points BBUnderStat12 1.2.016. O Ask Your T Suppose there are 30 people at a party. Do you think any two share the same birthday? Let's use the random-number table to simulate the birthdays of the 30 people at the party Ignoring leap year, let's assume that the year has 365 days. Number the days, with 1 representing January 1, 2 representing January 2, and so forth, with 365 representing December 31. Draw a random sample of 30 days (with...

  • please help me understand this problem. k people in a room. We would like to find...

    please help me understand this problem. k people in a room. We would like to find the probability that any two people 5. Suppose that there are have birthdays within a day of each other (which we'll call "near-day birthdays"). The number of pairs and the probability that any two people are born within a day of each other is of people would be S4Therefore, we would expect the average number of near-day birthday pairs to be be a Poisson...

  • (1 point) Consider the experiment, called the birthday problem, where our task is to determine the...

    (1 point) Consider the experiment, called the birthday problem, where our task is to determine the probability that in a group of people of a certain size there are at least two people who have the same birthday (the same month and day of month). Suppose there is a room with 10 people in it, find the probability that at least two people have the same birthday, Ignore leap years; assume each year has 365 days. Answer

  • A surprising result that appears in many elementy discussion on probability is called the birthday problem....

    A surprising result that appears in many elementy discussion on probability is called the birthday problem. The question simply stated is that if we pola certain number of people, what is the probability that at least two of those people were bom on the same day of the you? To solve this problem, use the formula for computing the probability of a complement of an event. It is clear that duplication of some birthdays) = 1 - Pino duplications. Assume...

  • in python The birthday paradox says that the probability that two people in a room will...

    in python The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided n, the number of people in the room, is more than 23. This property is not really a paradox, but many people find it surprising. Design a Python program that can test this paradox by a series of experiments on randomly generated birthdays, which test this paradox for n = 5, 6, 7, ..., 50....

  • We have seen that the probability that at least two people in a group of 23...

    We have seen that the probability that at least two people in a group of 23 people share the same birthday is approximately 0.5. In this question we are interested in the probability that at least three people in a group of 23 people share the same birthday. Draw 23 numbers independently from the integers {1, 2, . . . , 365} with each number equally likely to be drawn. Let E be the event that at least one of...

  • 1. We roll two fair 6-sided dice. Compute the probabilities of the following events. (a) The...

    1. We roll two fair 6-sided dice. Compute the probabilities of the following events. (a) The sum is at most 6. (b) The sum is more than 6. (c) The sum is at most 6 and at least one die is a 4. 2. Consider the letters a,b,c. Suppose we draw 2 of the letters at random (allowing for repetition). Assume order matters. That is, ab is not the same as ba: Let A : The 2 letters are distinct....

  • program in python Randomness can be used to improve the performance of deterministic algorithms which need...

    program in python Randomness can be used to improve the performance of deterministic algorithms which need to make many choices. Rather than repeatedly making fixed, hard-coded choices, a pseudorandom number generator can be used to make dynamic, unbiased choices. If the benefits of "good" choices outweigh the costs of "bad" choices, a random selection of good and bad choices can improve the performance of an algorithm Let us explore this with the QUICKSELECT algorithm. Discovered by the influential computer science...

  • Can someone do 2,6,8,12 34 Exercises 187 EXAMPLE 7 GETTING FIVE HEARTS Find the probability of being dealt five bearts...

    Can someone do 2,6,8,12 34 Exercises 187 EXAMPLE 7 GETTING FIVE HEARTS Find the probability of being dealt five bearts SOLUTION The sample is the same as in Example 5. The event consists of all pos- hands that include five hearts and no non-hearts This involves cltegories (hearts and non-hearts), so we will use the Fundamental Count- hinciple and multiply the number of ways of getting five hearts and the sible number of ways of getting no non-hearts There are...

  • Please help me with this- I REALLY NEED IT RIGHT NOW

    3) The quality control department of a tire manufacturer randomly selects a number ofproducts from two production lines and records the results in the following table:Durability (thousand km)       < 50 50 – 55 55 - 60 60 - 65 >= 65Line A 7 13 30 20 10Line B 10 15 40 9 6a) Construct a 90% confidence interval for the difference in average durability ofproducts of two lines A and B.b) At the 5% level of significance, can...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT