Download presentation
Presentation is loading. Please wait.
Published byFranklin Foster Modified over 8 years ago
1
Intro CS – Probability and Random Numbers Lesson Plan 6a
2
Goals Students can explain random numbers and how computers can generate them Students can generate random numbers Students can use the computer to simulate random number experiments to observe probability statistics Students can predict probability statistics for a given problem Students can express probability as ratios, decimals, and percentages Students can write code to generate probability statistics as ratios, decimals, and percentages
3
Objectives Students are introduced to random number generation by computers and how they can be used to simulate chance Students are given real probability problems to code and solve Results are demonstrated through predications, demos of running code, and displayed results
4
Pre Requisites Knowledge of IF blocks, Loops (to simulate mutiple trials), variables (to capture results) Basic Understanding of BYOB
5
Materials Slides with examples (or present on whiteboard) PCs with Chrome browser to access Snap web site
6
Lesson Description Students learn about random number generation in computers, and how it can be used simulate probability experiments Students practice and extend examples Students solve probability problems using code and the computer Students analyze their and others’ solutions, and collaborate towards shared solutions
7
Lesson Procedure Warm-up: Define/research what probability is, with an example. Research an example of how random numbers are used with computers to simulate chance Quick review of IF block, Variables, and Loops Introduce PICK RANDOM through student investigation and observation of sample work Give exercises for in class practice Walk the room answering questions, looking over the shoulder, asking questions, etc. Check off solutions for completeness and accuracy Review
8
Closure/Conclusion Summary Random numbers are a powerful way to simulate real world problems and introduce random behaviors into normally predictable code Future thinking: Discuss Monte Carlo simulations as they relate to Finance, Airplane Boarding Optimization, Sporting Event Results Ask questions on what is confusing or needs more time/practice
9
Random Numbers Lesson 5
10
Warm-up 0 Research/define probability, with a real-life example 0 Research another example of how computers are used to simulate chance
11
Review: IF blocks What are IF Blocks? IF blocks are used to help make decisions and branch your code. When the IF Block statement is true, whatever is contained inside the decision block is done Other blocks that use logic: IF/ELSE, Repeat Until, Wait Until
12
Review: Variables 0 Variables are places we can store results/values 0 Variables can be changed any time 0 Variables can be incremented by one to count things
13
Review: Loops 0 Used to repeat things a few to many, many times 0 Can repeat: 0 Forever (FOREVER block) 0 A specific number of times (REPEAT 10 block) 0 Until a test is True (REPEAT UNTIL block)
14
Generating Random Numbers 0 Usually, computers are very predictable 0 3+5 will also equal 8 for a computer 0 Spell checking, etc. 0 Sometimes we want computers to simulate life by being less predictable 0 We can use Random Numbers to: 0 Simulate chance (rolling dice, unpredictable events, etc.) 0 Track results in variables 0 Run thousands/millions of simulations very fast 0 We use the Pick Random block (on the green tab)
15
Investigation 0 Pair up. If you get stuck, ask another pair. 0 Simulate the following by having a sprite Say: 0 the result of rolling one six-sided die 0 the result of rolling two, three, four, or five six-sided dice 0 the result of rolling one ten-sided die 0 the result of picking a random card from a deck 0 sprite must say "Ace of Clubs", "6 of Hearts", etc. 0 Hint: use Join block on green tab to put words/numbers together, and IF blocks
16
When to use Pick random 0 When you want to simulate chance: 0 50/50 0 99/1 0 When you want to wait a random amount of time 0 Wait (pick random 6 to 10) 0 When you want to pick a random thing from a list of things 0 Picking a word in Hangman (future project in class) 0 When you want to make game behavior unpredictable 0 Sometimes go left, sometimes right, etc.
17
Coding problem 0 Write the following programs: 0 Computer rolls 2 dice, calculate the probability of each roll (2-12) 0 Use the computer to roll 5 dice to play Yahtzee 0 Roll dice, pick all/some/none to keep, repeat 3 times 0 Mark (on paper, write code), to track which scores to take after 3 roles 0 Repeat until can't play, or all categories filled
18
Review 0 You’ve just learned the basics of random numbers and using computers to measure probability 0 Simulate chance 0 Experiment to calculate results 0 Future thinking: Monte Carlo calculations 0 Finance: predict retirement outcomes 0 Sports: predict team scores 0 Airplane boarding optimization: predict and test models
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.