Presentation is loading. Please wait.

Presentation is loading. Please wait.

LESSON 12 - Loops and Simulations

Similar presentations


Presentation on theme: "LESSON 12 - Loops and Simulations"— Presentation transcript:

1 LESSON 12 - Loops and Simulations
UNIT 5 – 1/11/18

2 In this lesson you will:
Use a while loop in a program to repeatedly call a block of code. Use variables, iteration, and conditional logic within a loop to record the results of a repeated process. Identify instances where a simulation might be useful to learn more about real-world phenomena. Develop a simulation of a simple real-world phenomenon.

3 Vocabulary Alert: Models and Simulations - a program which replicates or mimics key features of a real world event in order to investigate its behavior without the cost, time, or danger of running an experiment in real life.

4 In this lesson, you gain more practice using while loops as you develop a simulation that repeatedly flips coins until certain conditions are met.

5 The ability to model and simulate real-world phenomena on a computer has changed countless fields. Researchers use simulations to predict the weather, the stock market, or the next viral outbreak.

6 Scientists from all disciplines increasingly rely on computer simulation, rather than real-life experiments, to rapidly test their hypotheses in simulated environments.

7 Programmers might simulate users moving across their sites to ensure they can handle spikes in traffic, and of course videogame and virtual reality technology is built around the ability to simulate some aspects of the real world.

8 The speed and scale at which simulations allow ideas to be tested and refined has had far-reaching impact, and it will only continue to grow in importance as computing power and computational models improve.

9 Everyone gets a coin and the Worksheet - Flipping Coins

10 Flip a coin until you get 5 total heads
Flip a coin until you get 5 total heads. Then again until you get 3 heads in a row. Record your results and predict the highest result in the class.

11 We’re going to run two simple experiments
We’re going to run two simple experiments. Use your worksheets to keep track of your results (by writing “H” or “T” for each flip) but keep them a secret for now.

12 Experiment 1: Groups will flip their coins as many times as it takes in order to get 5 heads total Experiment 2: Groups will flip their coins as many times as it takes to get 3 heads in a row

13 Let’s have a little competition
Let’s have a little competition. You should have recorded your results for your two experiments. Based on your experiment, predict, among every group in the class the most and fewest flips needed to complete each of the experiments.

14 That was pretty interesting with only 5 total heads or a streak of 3 heads. If we want to run this experiments for higher numbers of heads or longer streaks of heads however, we’ll quickly find that it’s tedious to do once, let alone many times. Luckily we know now that we can use loops to repeatedly perform commands, so we’re going to simulate these larger experiments instead.

15 Get into App Lab: Loops and Simulations Develop a simulation in App Lab that allows you conduct the experiments from the warm-up with many more coins. Repeat the warm-up activity using the simulation and update hypotheses as a result.

16 Insights: The following insights should arise from this experiment:
Total Heads: When trying to flip 5 heads, it is quite possible that it will only take 5 flips, but it may also easily take 15 or 20. Relative to the number of heads you are looking for, this is a massive range! When you are trying to flip 10,000 heads the likely range is typically between 19,000 and 21,000, and typically much closer. As you are looking for more flips, the relative width of the likely window shrinks. Longest Streak: When trying to find a streak of 3 heads it will typically take between 3 (it's always possible!) and 20 flips, though of course it may take longer. Even slightly longer streaks of heads, however, will rapidly increase the average time it takes to find that streak. Looking for a streak of 12 heads might occasionally happen in fewer than 100 flips, but it can also easily take tens of thousands. As the length of the streak increases, the number of flips it takes to find that streak grows rapidly.

17 The goal of this lesson is not for you to walk away knowing the precise mathematical relationship between the number of coins flipped and the number of heads observed or the longest streak of heads. Instead you are supposed to appreciate that questions that might be impossible or hard to address by hand are possible to examine by using computer simulation. Just as developing a mathematical model is one way to address a problem, so too is developing a simulation.

18 Pause Point - Make a Hypothesis
Use this level to describe the fact that you will be making a simulation of flipping coins. Make a prediction for the outcomes of the experiments you will run. Make sure you make this prediction before moving on. You should record your predictions in the space provided on your worksheets.

19 For a grade, show me: Level #6 – 10,000 heads Level #10 – STREAKS – 12 heads in a row Update your hypothesis Turn in your worksheet You have homework!

20 Conclusions for this lesson:
Not all problems are as easy to simulate as a coin flip of course, and we’ve even seen how some problems we can simulate still take a very long time to run. Simulations are an increasingly important tool for a variety of disciplines. Weather and traffic predictions are based on computer models that simulate weather patterns or people moving through a city. Scientific research, whether in physics, chemistry, or biology, increasingly uses simulations to develop new hypotheses and test ideas before spending the time and money to run a live experiment. Before you use most of your favorite websites and apps, they will be tested by simulating high levels of traffic moving across the server. Simulations take advantage of computers’ amazing speed and ability to run repeated tasks, as we’ve seen through our exploration of the while loop, in order to help us learn more about the world around us. As computers get ever faster and models improve, we are able to answer old questions more quickly and start asking new ones.


Download ppt "LESSON 12 - Loops and Simulations"

Similar presentations


Ads by Google