1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
adelina 88 [10]
3 years ago
15

The birthday problem is as follows: given a group of n people in a room, what is the probability that two or more of them have t

he same birthday? It is possible to determine the answer to this question via simulation. Using the starting template provided to you, complete the function called calc birthday probability that takes as input n and returns the probability that two or more of the n people will have the same birthday. To do this, the function should create a list of size n and generate n birthdays in the range 1 to 365 randomly, inclusive of the end-points 1 and 365. It should then check to see if any of the n birthdays are identical. The function should perform this experiment 106 times and calculate the fraction of time during which two or more people had the same birthday. The function will be called as follows from your main program
Import random

def calc_birthday_probability (num_people):
num_tries = le6
num_duplicates = 0

""" FIXME: Complete this function to return the probability of num_people in the room having the same birthday. """

return num_duplicates/num_tries
def main ():
num_people = 10
p = calc_birthday_probability (num_people)

num_people = 20
p = calc_birthday_probability (num_people)

return

# Main program
if __name__ == "_main_":
random.seed (2020)
main ()
Computers and Technology
1 answer:
Julli [10]3 years ago
4 0

Answer:

import random

def calc_birthday_probability(num_people):

   num_tries = 1e6

   num_duplicates = 0

   tries = 0

   while tries < num_tries:

       total_birthday = {}

       for i in range(1, 366):

           total_birthday[i] = 0

       for count in range(num_people):

           birthday = random.randint(1, 365)

           if total_birthday[birthday] != 0:

               num_duplicates += 1

               break

           total_birthday[birthday] += 1

       tries += 1

   return num_duplicates/num_tries

def main():

   num_people = 10

   p = calc_birthday_probability (num_people)

   print(p)

   num_people = 20

   p = calc_birthday_probability (num_people)

   print(p)

   return

if __name__ == "__main__":

   random.seed(2020)

   main()

Explanation:

  • Run the loop until the value of tries is less than num_tries to do number of trials.
  • Run the loop to create the desired number of birthdays by generating random numbers.
  • Increase  the num_duplicates  variable by 1, if the birthday has  already occurred.
  • Lastly define and then call the main function.

You might be interested in
(Best Buy Part A) At a Best Buy store, the forecast for the annual demand of a Motorola cell phone is 15600. Demand forecasts ar
Nataly_w [17]

Explanation:

a. The computation of the economic order quantity is shown below:

= \sqrt{\frac{2\times \text{Annual demand}\times \text{Ordering cost}}{\text{Carrying cost}}}

= \sqrt{\frac{2\times \text{\15,600}\times \text{\$400}}{\text{\$5}}}

= 1,580 units

The carrying cost is

= $50 × 10%

= $5

b. The number of orders would be equal to

= Annual demand ÷ economic order quantity

= 15,600 ÷ 1,580

= 9.87 orders

Ordering cost = Number of orders × setup cost per order

= 9.87 orders × $400

= $3,949.37

c. The average inventory would equal to

= Economic order quantity ÷ 2

= 1,580 units ÷ 2

= 790 units

Carrying cost = average inventory × carrying cost per unit

= 790 units × $5

= $3,950

c. Now the total cost

= Setup cost + carrying cost

= $3,949.37 + $3,950

= $7,899.37

8 0
3 years ago
Drag the correct type of update to its definition.
Sophie [7]

Answer:

  • PRI

The connection between a mobile device and radio tower.

  • Baseband

The chip that control the radio frequency waves within a device.

  • PRL

A list of radio frequencies.

Baseband can be defined as a  technology within the the mobile devices that creates and manages interface to wireless network such as radio transmitters and the radio receivers.

Primary Rate Interference PRI on the other hand is a connection that is configured by many countries. This configuration has specified data and control channels with specified speed for specified countries depending upon the T-carriers and E-carriers.

3 0
3 years ago
What is credibility in the often-used framework of quality criteria?
andreyandreev [35.5K]

The correct Answer is  A) Confidence in the truth value of the findings.

Explanation:

refers to confidence in the truth value of the findings, is sometimes said to be the qualitative equivalent of internal validity.

6 0
3 years ago
What are the steps to open the Custom AutoFilter dialog box?
uranmaximum [27]

Answer:

data, sort and filter, text filters

Explanation:

ed 2020

7 0
3 years ago
Read 2 more answers
identify three ways we use analog and digital signals in our everyday lives. Describe how radio telescopes are used to explore s
spayn [35]
We use analog and digital signals in our everyday lives with the radio, the cell phone and with our own computers. our computers and our cell phones are all digital now but radio's are still considered analog. Radio telescopes explore space by using radio waves and signals to almost like scan space and collect data like a sonar in a submarine. 
8 0
3 years ago
Read 2 more answers
Other questions:
  • What file would you edit to restrict the number of simultaneous logins a user can employ??
    14·1 answer
  • When sending an electronic cover letter, an e-mail address is sufficient contact information.
    10·2 answers
  • Whats the size of a short bond paper in microsoft word?
    10·1 answer
  • How many bits would be needed to count all of the students in class today there is 20 students
    6·1 answer
  • Higher-speed Ethernet technologies use an electronic device known as a Hub rather than a switch True/False
    15·1 answer
  • write a script to check command arguments. Display the argument one by one (use a for loop). If there is no argument provided, r
    6·1 answer
  • You are going to create an Arduino sketch where you have two push buttons, one piezo, one
    10·1 answer
  • In order to personalize your desktop, you may click on: Start&gt;settings&gt;Personalization . . .
    9·1 answer
  • X274: Recursion Programming Exercise: Cannonballs Spherical objects, such as cannonballs, can be stacked to form a pyramid with
    7·1 answer
  • A leading global vendor Of computer software hardware for computer mobile and gaming systems and cloud services it's corporate h
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!