# 4.7. Pseudo Random Numbers¶

This lesson describes how computers model randomness using relatively simple mathematical functions, such as modular arithmetic (sometimes called clock arithmetic). It reinforces the enduring understanding that models use abstractions — in this case mathematical constructs — to represent phenomena.

### Professional Development

Complete the activities for Mobile CSP Unit 4 Lesson 4.7: Pseudo Random Numbers.

## 4.7.1. Learning Activities¶

### Estimated Length: 45 minutes

• Adapted from the Randomness in Stochastic Models lesson plan.
• Hook/Motivation (10 minutes) Ask students for words or situations where they might expect to see randomness present. Write these words on the board. Show them sets of numbers and ask them which they think are random and which are not.
• 1, 2, 3, 4, 5
• 6, 5, 6, 3, 3
• 4, 4, 4, 4, 4
• 3, 2, 3, 4, 1
Explanation: The answer is that we don’t know which of the above sets of numbers are randomly-generated. The fact that some of them seem to resemble a pattern reflects on what we have learned and experiences, not whether they are random. To an alien race, option d might follow a pattern they are aware of. The fact that we don’t see randomness in options a and c is part of a larger philosophical discussion known as the Anthropic Principle.
What makes numbers random are not the results but the method used to determine the numbers.
Dilbert Joke: Here's a nice cartoon from Scott Adams' Dilbert Cartoon Strip that reinforces the previous point.
• For each scenario, ask the students to describe what they would do to ensure their method was random:
• Picking a card from a deck. A: Example - Close your eyes while choosing.
• Rolling a dice. A: Example - Placing the dice in a cup to shake.
• Driving a car to a destination. A: Example - Flip a coin to determine the direction at each intersection.
• Selecting a word in the dictionary. A: Example - Letting the book fall open to a page.
• Can a computer generate random numbers? Why or why not? A: 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.
• Experiences and Explorations (30 minutes):
• Generate Random Sequences (10 minutes): Have the students complete the first set of activities (up to the table) to generate an imaginary sequence of coin flips.
• Optional - Chaos Game (10 minutes): With the students, before you say anything, place three large dots on the board so that they represent the corners of an equilateral triangle. Label the dots A , B, and C. Explain to the class that you are going to start at a random place on the board, place a dot, and call on them one by one to have them choose A, B, or C. Then, place a small dot half way between the last dot drawn and the corner called out by the student. Once everyone has had a chance to call out a corner, ask the class if anyone sees a pattern. Ask what the class thinks will happen if this process is continued for a really long time. Demonstrate the computer version of The Chaos Game, which results in a Sierpinski's triangle pattern emerging. Explain that the seemingly random process resulted in a familiar pattern and that is similar to how pseudo number generators work. (Never seen the Chaos Game? Watch this video to see it in action.)
• Lecture (15 minutes): Either show the videos on Mobile CSP or use the slides to present the material to the students. If you are showing the slides, you can use this handout to have them complete the exercises during the presentation.
• Video (5 minutes): Show the video on slot machines at casinos, which will be needed for their portfolio reflection.
• Rethink, Reflect and/or Revise (5 minutes): Summarize the main points about randomness and then have students complete their portfolio reflection.

### AP Classroom

The College Board's AP Classroom provides a question bank and Topic Questions. You may create a formative assessment quiz in AP Classroom, assign the quiz (a set of questions), and then review the results in class to identify and address any student misunderstandings.The following are suggested topic questions that you could assign once students have completed this lesson.

Suggested Topic Questions:

• Topic 3.3 Mathematical Expressions
• Topic 3.9 Developing Algorithms

### Assessment Opportunities

Solutions:

Assessment Opportunities

You can examine students’ work on the interactive exercise and their reflection portfolio entries to assess their progress on the following learning objectives. If students are able to do what is listed there, they are ready to move on to the next lesson.

• Interactive Exercises:
• Portfolio Reflections:
LO X.X.X - Students should be able to ...
• In the XXX App, look for:

### Differentiation: More Practice

If students are struggling with lesson concepts, have them review the following resources:

### Differentiation: Enrichment

If you want a deeper dive into the Chaos Game, the lesson can be extended by having the students play the game themselves on paper first, and then use the online simulation to see the patterns. A full lesson plan is included on the Shodor site.

## 4.7.2. Professional Development Reflection¶

Discuss the following questions with other teachers in your professional development program.

• How does this lesson help students toward understanding how pseudo randomness is used to model randomness in computer simulations and games?
• Is there anything else you would need to have or know to teach this lesson effectively? What specific elements of this lesson (examples, activities, formative assessments) might you want to change?

I am confident I can teach this lesson to my students.
• 1. Strongly Agree
• 2. Agree
• 3. Neutral
• 4. Disagree
• 5. Strongly Disagree