![Page 1: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/1.jpg)
DATA 8Fall 2016
Slides created by Ani Adhikari and John DeNero
Lecture 13, September 23Simulating Random Phenomena
![Page 2: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/2.jpg)
Announcement● Project 1 Checkpoint on Tuesday.
● No homework today (but there will be homework next Friday). Instead:○ Read the text○ Use the Interact feature and run the live
notebooks; experiment on Python Playground○ Summarize the concepts, not just the code
![Page 3: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/3.jpg)
Simulation
Using a computer to re-create random phenomena
![Page 4: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/4.jpg)
Random Selectionnp.random.choice● Selects at random● with replacement● from an array● a specified number of times
np.random.choice(array_name, sample_size)
![Page 5: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/5.jpg)
Conditional Statement if <if expression>: <if body> elif <elif expression 0>: <elif body 0> elif <elif expression 1>: <elif body 1> ... else: <else body>
![Page 6: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/6.jpg)
for Statement (“loop”)for item_name in sequence: body
For example, np.arange(5)
For example,i
(Demo)
![Page 7: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/7.jpg)
Caution ...
![Page 8: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/8.jpg)
How many heads in 100 tosses?
50???
(Demo)
![Page 9: Simulating Random Phenomena - data-8.github.iodata8.org/fa16/lectures/lec13.pdf · 2021. 3. 2. · Simulating Random Phenomena. Announcement Project 1 Checkpoint on Tuesday. No homework](https://reader035.vdocument.in/reader035/viewer/2022070213/61089c81cf6eff506573b842/html5/thumbnails/9.jpg)
Monty Hall Problem