We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byDexter Cotterell
Modified over 2 years ago
91.166 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 Exercise 3 Suppose that we’re holding a party and that “n” people show up. If “n” is 1, we are guaranteed that nobody will have the same birthday as somebody else. for n = 1, probability of no shared birthdays = 1 If the party is a bit more successful and two people show up, the probability of nobody having the same birthday as somebody else is the probability that the second person wasn’t born on the same day as the first person. If we assume that all possible birthdays are equally probable, this is 365/366. for n = 2, probability of no shared birthdays = 1 * (365/366) If things really start to warm up and we get three people, the probability of nobody having the same birthday as somebody else is the probability that the first two people don’t have the same birthday (see above) multiplied by the probability that the third person wasn’t born on the same day as either of the first two people. for n = 3, probability of no shared birthdays = 1 * (365/366) * (364/366) And so on and so on. For six people, for example, the probability of nobody having the same birthday as somebody else is: 1 * (365/366) * (364/366) * (363/366) * (362/366) * (361/366) In all cases, the probability of at least two people sharing a birthday is 1 minus the probability that there are no shared birthdays. probability of shared birthday = 1 – probability of no shared birthdays Throughout the above, probabilities have been expressed as they usually are in mathematics – as a number between zero and one. A probability of zero means that something is impossible, and a probability of one means that something is certain. In everyday life (e.g. in weather forecasts) probabilities are often expressed as percentages, with a probability of 100% meaning that something is bound to happen. Going from one convention to the other is as simple as multiplying (or dividing) by 100.
91.166 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 2 You are to write a program which reads in the number of people at a party and outputs the probability (expressed as a percentage) that at least two people will share the same birthday. Running the sample executable supplied should give the idea. Try using it to work out how large a party must be for there to be a better than even chance that two people will share the same birthday. You may be surprised at how few people are required. Some notes: 1/ Your program should loop, like the sample executable, and repeatedly calculate probabilities until zero or a negative value is entered. 2/. In presenting formulae, it is reasonable to write 365/366. Writing the same thing in a C++ program, on the other hand, can cause problems… 3/. Don’t forget to consider that parties can get really big (e.g. have more than 366 people show up). 4/. If a number is really close to 100.0, it will appear as 100.0 when it is output (unless manipulators are used to force the display of a large number of decimal places). To get around this problem, have your program output “it is almost certain…” when the calculated probability exceeds 99.9999%. To see this feature in operation, try the sample executable for 96 and 97 people. For more advanced students (this part is optional): 1/. Modify the formulae to reflect the fact that fact that February 29 th is less likely than other birthdays. 2/. Experiment with using I/O manipulators to force the display of a greater number of decimal places. 3/. Have your program give users the option of working out how many people must be present at a party to achieve a specified probability of at least two people sharing a birthday.
ECOR 1606 Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 Exercise 9 Imagine a beam sticking out of a wall with.
Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 Exercise 6 This assignment is probably best started by running.
Copyright ©2004 The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4-1 Probability and Counting Rules CHAPTER 4.
1 Suppose you are throwing a surprise party for your friends. However, it is essential that no two people at the party share a birthday. How many people.
Chapter 4 Repetitive Execution. 2 Types of Repetition There are two basic types of repetition: 1) Repetition controlled by a counter; The body of the.
Copyright © 2002, Department of Systems and Computer Engineering, Carleton University 1 Exercise 10 The study of thermodynamics involves a lot of.
Scientific Notation What is scientific Notation? Scientific notation is a way of expressing really big numbers or really small numbers. It.
1. Definition and General Structure 2. Small Example 1 3. Simplified Structure 4. Short Additional Examples 5. Full Example 2 6. Common Error The for loop.
9-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
Copyright © 2000, Department of Systems and Computer Engineering, Carleton University 1 While’s – The Basic Idea Set of operations is repeated as.
11/16/2015Slide 1 We will use a two-sample test of proportions to test whether or not there are group differences in the proportions of cases that have.
Simplify Radical Expressions Using Properties of Radicals.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
EXPONENTS X2X2 X TO THE SECOND POWER OR X SQUARED X IS CALLED BASE 2 IS CALLED EXPONENT Use x as a factor 2 times X * X.
Links HOME Options Pricing Model-based pricing of options is a relatively new phenomenon. Until the early 1970's option premiums were determined by offer.
Copyright © 2000, Department of Systems and Computer Engineering, Carleton University 1 If’s – The Basic Idea “Program” for hubby: take out garbage.
9-1 Iteration: Beyond the Basic PERFORM Chapter 9.
Python Repetition. We use repetition to prevent typing the same code out many times and to make our code more efficient. FOR is used when you know how.
Transforms What does the word transform mean?. Transforms What does the word transform mean? –Changing something into another thing.
Exponents. 6³ Exponent Base 6³ is read “Six Cubed” 6³ = 6 x 6 x 6 6³ = 216.
Scientific Notation. What is scientific Notation? Scientific notation is a way of expressing really big numbers or really small numbers. It is most often.
ECE 250 Algorithms and Data Structures Douglas Wilhelm Harder, M.Math. LEL Department of Electrical and Computer Engineering University of Waterloo Waterloo,
Lecture for Week Spring. Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
Ζ Standard Form Dr Frost Objectives: Appreciate the need to put big and small numbers in a more readable form, how to write numbers in standard form, and.
1-1 Copyright © 2015, 2010, 2007 Pearson Education, Inc. Chapter 13, Slide 1 Chapter 13 From Randomness to Probability.
Probability. Contents 1. Introduction to probability terminology 2. Probability models to compare relative frequency of events with theoretical probability.
Chapter 5 Using Data and COBOL Operators. Initializing Variables When you define a variable in WORKING- STORAGE, you also can assign it an initial value.
1.4-5: Multiplying Integers: Basic Rules. Ways to Express multiplication Remember: All of these mean the same thing: Five times four 5 × 4 5 · 4 5(4)
PEMDAS, Calculators, %s, Decimals, & Zeros. P. stands for “Parentheses”… Cute story.
Evaluating What’s Been Learned. Cross-Validation Foundation is a simple idea – “ holdout ” – holds out a certain amount for testing and uses rest for.
Copyright © 2010 Pearson Education, Inc. Unit 4 Chapter 14 From Randomness to Probability.
BMTRY 789 Lecture 6: Proc Sort, Random Number Generators, and Do Loops Readings – Chapters 5 & 6 Lab Problem - Brain Teaser Homework Due – HW 2 Homework.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
The importance of sequences and infinite series in calculus stems from Newton’s idea of representing functions as sums of infinite series. For instance,
Chapter 2 - Algorithms and Design print Statement input Statement and Variables Assignment Statement if Statement Flowcharts Flow of Control Looping with.
Binary Arithmetic Math For Computers. Huh? Binary numbers are NUMBERS That means you can add, subtract, multiply, and divide = 4 In Binary: 10 +
Copyright © 2010, 2007, 2004 Pearson Education, Inc. Chapter 14 From Randomness to Probability.
Line Continuation, Output Formatting, and Decision Structures CS303E: Elements of Computers and Programming.
Copyright © 2010 Pearson Education, Inc. Chapter 14 From Randomness to Probability.
Scientific Notation SWBAT write the scientific notation for numbers given in standard form; write the standard form for numbers given in scientific notation;
Theoretical Probability WORDS: The ratio of the number of ways the event can occur to the number of possible outcomes. SYMBOLS: number of ways the event.
Common Logarithms, Base e, Natural Logs, Properties of Logarithms.
The Birthday Problem. The Problem In a group of 50 students, what is the probability that at least two students share the same birthday?
Chapter 6 Finding the Roots of Equations The Bisection Method Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
How do machines work?. What is a machine? Allows you to do work in a way that is easier Can be quite simple A machine changes at least one of three factors…
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
1 Chapter 2 - Algorithms and Design print Statement input Statement and Variables Assignment Statement if Statement Flowcharts Flow of Control Looping.
Probability Section 7.1. What is probability? Probability discusses the likelihood or chance of something happening. For instance, -- the probability.
1 Copyright © 2010, 2007, 2004 Pearson Education, Inc. All Rights Reserved. Basic Principle of Statistics: Rare Event Rule If, under a given assumption,
General Condition Loop A general condition loop just loops while some condition remains true. Note that the body of the loop should (eventually) change.
© 2017 SlidePlayer.com Inc. All rights reserved.