ECT Lesson Plan: Randomness in Stochastic Models
Lesson plan at a glance...
| In this lesson plan… |
Most of the experiments students perform in class are deterministic. The expected outcome is the same every time. However, modern scientific research is often stochastic, that is, it depends on random variables and probability. In this lesson, students will be introduced to methods used to create random numbers as well as ways in which they can be used in scientific experiments. This lesson will cover the following CT concepts: pattern recognition and algorithms.
If students are using computers, confirm that all students’ computers are turned on, logged-in, and connected to the Internet | 3 to 5 minutes | |
This lesson uses VPython. We recommend you use the latest version of VPython (6.x) which requires an older version of Python (2.x). If you have a 64-bit version of Windows you should use a 64-bit version of both Python and VPython.
| 5 to 10 minutes 5 to 10 minutes | |
Open the ECT Pseudocode Guide | 1 minute |
20 minutes | |
30 minutes | |
45 minutes | |
10 to 20 minutes |
Activity Overview: Students will explore what randomness is in a set of numbers and how to determine if a set of numbers is truly randomized. Culture has made “randomness” a common word, and with that students may have misconceptions about what numbers might or might not be random. In this activity, students will explore what determines if a number is random and how that relates to the generation of the numbers and not the numbers themselves. This activity explores the relationship between randomness and patterns in order to recognise randomness (not patterns).
Notes to the Teacher: Culture has made “randomness” a common word, and with that students may have misconceptions about what numbers might or might not be random. |
Activity: Ask students for words or situations where they might expect to see randomness present. Write these words on the board. Next, show them sets of numbers and ask them which they think are random and which are not.
Ask students the following questions. Q1: If we were to roll five dice, would it be possible to get each of the options above? Q2: Are any of the options above more likely than the other if all of the dice are rolled at the same time? Q3: There are stories of people who have won the lottery more than once. How does this affect the randomness of the lottery? Q4: For each scenario, describe what you would do to ensure your method was random:
Q5: Can a computer generate random numbers? Why or why not? |
Teaching Tips:
|
Assessment: A1: Yes A2: No A3: It doesn’t. While the probability of someone winning the lottery once let alone multiple times is very unlikely, randomness has to do with the method of obtaining the results and not the results itself. Unlikely does not mean that it is impossible. A4: Answers will vary, below are a few possible answers.
A5: A computer is deterministic, that is, it follows instructions and is incapable of making independent decisions needed for creating a random number. However, some random number generators use information from sensors or human interaction to generate real random numbers. Pseudo-random numbers have faults but are sufficient for most applications. |
Activity Overview: In this activity, students will practice an activity in which we simulate a one-dimensional random walk using a flipped coin. In this activity, students will will simulate a one-dimensional random walk using a coin to determine if they should move forwards or backwards. Students look for patterns and lack of patterns to give them an overall understanding of the problem and to generalize and predict behavior of multiple trials.
Activity:
Example pseudocode:
Example of One-Dimensional Random Walk Code
Sample outputs: How many trials? 100 How many flips per trial? 100 [664, 592, 522, 434, 383, 322, 335, 307, 337, 330] How many trials? 100 How many flips per trial? 100 [595, 541, 511, 472, 433, 336, 342, 359, 351, 341] Ask students the following questions: Q1: The “coin flip” in line 14 is pseudo-random. Do you see a pattern in the results that implies that this is not random enough for the program? Q2: How does the result of this experiment compare to the class activity? Q3: What is the purpose of the continue statements in line 20? Q4: Try a relatively large number of trials and flips (1000 or 10000). Does the data seem to favor one spot over the other? What about a subset (e.g. lower numbers, higher numbers, middle)? Q5: How would the pattern of the data change if when the students_position exceeded the boundaries, it wrapped around to the other side. Example: If the student is in position 0 and flips Tails, they move to position 10. Q6: With this experiment, is there an expected outcome, can you predict what will happen over the long run? Q7: After line 20’s, continue add a new line and type print “Out of money”. Why do you think one name for this experiment is Gambler’s ruin (http://wikipedia.org/wiki/Gambler%27s_ruin)? |
Teaching Tips:
|
Assessment: A1: There shouldn’t be one. It is random enough. A2: The results should be similar, the exact number may differ for each position, but it will still be randomly distributed. A3: If changing the student’s position would put them outside the boundary of boxes, the position is not changed and the program continues with the next trial. A4: In this experiment the data may tend to be closer to the boundaries edge because the loop prevents the position from going beyond it. A5: Since all positions are equally likely now, the data would be more likely to be evenly distributed. A6: While general conclusions can be made, there is no expected outcome, all scenarios are equally likely. A7: If the loop gets to a boundary, this is equivalent in a casino to running out of money. A gambler with a finite amount of money playing a fair game against a casino with an infinite amount of money will lose all of their money eventually. In reality, casinos do not have an infinite amount of money but one that far exceeds any individual’s funds. This is why casinos are able to stay profitable without cheating, in the end “The House always wins”. |
Activity Overview: What happens if you introduce two degrees of freedom into a random walk? Students will now use computer programming to simulate a two-dimensional random walk which models well the brownian motion of particles diffusing through a medium. In this activity, students will use a Python program to simulate brownian motion using a two-dimensional random walk model. Students modify their algorithm to adapt it to new situations. Students also look for patterns and lack of patterns to give them an overall understanding of the problem and to generalize and predict behavior of multiple trials.
Notes to the Teacher: The video in the activity shows an experiment where ink is added to two jars of different temperatures. The jar on the right has a temperature of 79.6 degrees Celsius and the one on the left, a temperature of 80.8 degrees celsius. Ink is added to the jars and the ink on the left seems to disappear because it diffuses more quickly into the water. This is because of the higher energy of the water on the left moving the particles much more quickly away from each other. Brownian Motion is the phenomena of particles moving through a medium like a gas or liquid. A random walk can be used to simulate this motion quite effectively. |
Activity:
Example Pseudocode for a 2 Dimensional Walk: a. Choose a random direction (0, 90, 180, 270 degrees) b. Move a certain distance in that direction c. Repeat steps 1 and 2.
Example of Two-Dimensional Random Walk Code (using only Python)
Sample outputs: How many steps? 100 Optional Example of Three-Dimensional Random Walk Code (using VPython)
Sample output: (zoom by holding the middle mouse button, pan with the right mouse button) How many steps?100 (The darker line means the “walk” retraced previous steps) Ask students the following questions. Q1: What was the difference between the two jars of water? Q2: Why is that affecting the way the ink diffuses? Q3: What would be the difficulty in coming up with a formula or model that models Brownian Motion? Q4: How does a random walk simulate brownian motion of particles in water? Q5: Random walks are used to predict the diffusion rate of medicines into cells. How can a random simulation tell us specific information? Q6: What change could you make to the VPython code to make it 2D? Q7: What is the purpose of rate(10)in line 18 of the VPython code? Hint: Try commenting it out or increasing/decreasing the number. Q8: In the VPython code, why was choice used rather than randint? Q9: In the video shown at the beginning, the water with the higher temperature diffused the ink molecules more quickly. How could you modify either code to simulate a higher temperature/velocity? |
Assessment: A1: The one on the left has a higher temperature than the one on the right. A2: The higher temperature is causing the ink particles to move away from each other faster until they are no longer visible. A3: Too many interactions between particles, a seemingly endless number of possibilities and combinations. A4: Particles are colliding at such a high rate in the water that their movements are essentially random. A5: The simulation is random but if performed numerous times, it can give a general timeframe for how long it would take to diffuse into a cell. In a real situation all probabilities are possible. A6: Comment out line 20 (add a # at the beginning of the line). A7: Slows down the code so you can see it being traced out. Removing it would make the walk appear instantly. A8: So the particle would always be moving, a zero would give it zero velocity which would be impossible in a ideal fluid. A9: Increased, the size of the step. |
Activity Overview: Now, it is time to assess student understanding of randomness and random walk simulations. In this activity, students will assess their understanding of random walks. Students will be assessed on algorithms, pattern recognition, pattern generalization, and the distinction between patterns and randomness.
Notes to the Teacher: Lead students through an assessment activity to assess understanding and skills. |
Activity: Have students who have answered the questions throughout assess the other students’ understanding of methods for obtaining a random number. Discuss the below question with students. Q1: Some models of stock market fluctuations involve a random walk. Why or why not is this a good idea? |
Assessment: A1: While it is effective to a degree, a random walk requires that each step be independent (not influence) the next step. Some would argue that unlike natural phenomena, such as water molecules, stock traders do have prior knowledge that influences the movement of the market. |
Learning Objectives | Standards |
LO1: Students will be able to define randomness and label the output of a situation, scenario, or task as random or not random or pseudorandom. | Core Subject CCSS HS Math S-MD 6: Use probabilities to make unbiased decisions (e.g., drawing by lots, using a random number generator). CCSS MATH.PRACTICE.MP2: Reason abstractly and quantitatively. CCSS MATH.PRACTICE.MP7: Look for and make use of structure. Computer Science AUSTRALIA 8.4 (Collecting, managing and analyzing data): Analyse and visualise data using a range of software to create information; and use structured data to model objects or events. CSTA L3A.CT.8: Use modeling and simulation to represent and understand natural phenomena. UK 4.2: Develop and apply their analytic, problem-solving, design, and computational thinking skills. |
LO2: Students will be able to determine the relative probability of any outcome in a set of randomly-generated numbers. | Common Core CCSS.MATH.CONTENT.7.SP.C.5: Understand that the probability of a chance event is a number between 0 and 1 that expresses the likelihood of the event occurring. Larger numbers indicate greater likelihood. A probability near 0 indicates an unlikely event, a probability around 1/2 indicates an event that is neither unlikely nor likely, and a probability near 1 indicates a likely event. CCSS.MATH.CONTENT.7.SP.C.6: Approximate the probability of a chance event by collecting data on the chance process that produces it and observing its long-run relative frequency, and predict the approximate relative frequency given the probability. For example, when rolling a number cube 600 times, predict that a 3 or 6 would be rolled roughly 200 times, but probably not exactly 200 times. CCSS.MATH.CONTENT.HSS.CP.A.1: Describe events as subsets of a sample space (the set of outcomes) using characteristics (or categories) of the outcomes, or as unions, intersections, or complements of other events ("or," "and," "not"). Computer Science AUSTRALIA 6.4 (Creating digital solutions by: defining): Define problems in terms of data and functional requirements, and identify features similar to previously solved problems. CSTA L2.CT.1: Use the basic steps in algorithmic problem-solving to design solutions (e.g., problem statement and exploration, examination of sample instances, design, implementing a solution, testing and evaluation). UK 3.2: Understand several key algorithms that reflect computational thinking [for example, ones for sorting and searching]; use logical reasoning to compare the utility of alternative algorithms for the same problem. |
LO3: Students will be able to write pseudocode to correctly model a 1D and 2D or 3D random walk. | Core Subject CCSS.MATH.PRACTICE.MP4: Model with mathematics. MS-PS1-4: Develop a model that predicts and describes changes in particle motion, temperature, and state of a pure substance when thermal energy is added or removed. HS-PS1-5: Apply scientific principles and evidence to provide an explanation about the effects of changing the temperature or concentration of the reacting particles on the rate at which a reaction occurs. HS-PS3-2: Develop and use models to illustrate that energy at the macroscopic scale can be accounted for as either motions of particles or energy stored in fields. Computer Science CSTA L2.CT.14: Examine connections between elements of mathematics and computer science including binary numbers, logic, sets and functions. |
LO4: Students will be able to simulate multiple trials or events of a 1D or 2D random walk with Python code, recognize patterns and lack of patterns in the collected data, generalise and predict probabilities based on the randomness of the model or for a large number of trials, alter the code in order to produce a different result, and predict the output result of altered code of 1D and 2D or 3D random walk scenarios. | Core Subject CCSS.MATH.PRACTICE.MP4: Model with mathematics. MS-PS1-4: Develop a model that predicts and describes changes in particle motion, temperature, and state of a pure substance when thermal energy is added or removed. HS-PS1-5: Apply scientific principles and evidence to provide an explanation about the effects of changing the temperature or concentration of the reacting particles on the rate at which a reaction occurs. HS-PS3-2: Develop and use models to illustrate that energy at the macroscopic scale can be accounted for as either motions of particles or energy stored in fields. CCSS MATH.PRACTICE.MP2: Reason abstractly and quantitatively. CCSS MATH.PRACTICE.MP7: Look for and make use of structure. CCSS.MATH.PRACTICE.MP8: Look for and express regularity in repeated reasoning. CCSS.MATH.PRACTICE.MP5: Use appropriate tools strategically. Computer Science CSTA L2.CT.9: Interact with content-specific models and simulations (e.g., ecosystems, epidemics, molecular dynamics) to support learning and research. |
LO5: Students will be able to analyze a code and determine the purpose of a given function with the code. | Common Core CCSS MATH.PRACTICE.MP2: Reason abstractly and quantitatively. CCSS MATH.PRACTICE.MP7: Look for and make use of structure. CCSS.MATH.PRACTICE.MP3: Construct viable arguments and critique the reasoning of others. Computer Science |
Term | Definition | For Additional Information |
Pseudocode | A list of easily understood instructions used for developing algorithms. | |
Random | Numbers or objects selected where there is equal probability to the others in the set (e.g. each side of the dice is equally likely to be rolled) and zero ability to predict for each individual roll. | |
Stochastic Models | Equations and algorithms involving randomness and probability, which therefore may return a different output for any given input. It is usually not possible to work backwards to determine the inputs from the results and the equations/algorithms. |
Concept | Definition |
Pattern Recognition | Identifying trends and commonalities between data points, groups, or sets |
Pattern Generalization | Making predictions and testing models |
Algorithm Design | Creating an ordered series of instructions for solving similar problems |
Contact info | For more info about Exploring Computational Thinking (ECT), visit the ECT website (g.co/exploringCT) |
Credits | Developed by the Exploring Computational Thinking team at Google and reviewed by K-12 educators from around the world. |
Last updated on | 07/02/2015 |
Copyright info | Except as otherwise noted, the content of this document is licensed under the Creative Commons Attribution 4.0 International License, and code samples are licensed under the Apache 2.0 License. |
ECT: Randomness in Stochastic Models of