CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person,...
Transcript of CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person,...
![Page 1: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/1.jpg)
CS109: Probability for Computer ScientistsOishi Banerjee and Cooper RaterinkBased on slides by Lisa YanJune 22, 2020
1
![Page 2: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/2.jpg)
Lisa Yan, CS109, 2020
Quick slide reference
2
3 Introduction + Intro to counting LIVE
65 Counting II 01b_counting_ii
73 Pigeonhole Principle 01c_pigeonhole
79 Permutations I 01d_permutations
Today’s discussion thread: https://us.edstem.org/courses/667/discussion/79610(If you haven’t joined Ed yet, use this first: https://us.edstem.org/join/nhECh5)
![Page 3: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/3.jpg)
Welcome to CS109!
3
![Page 4: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/4.jpg)
Lisa Yan, CS109, 2020
Lecture with
• Turn on your camera if you are able, mute your mic in the big room
• Virtual backgrounds are encouraged (classroom-appropriate)
4
![Page 5: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/5.jpg)
Lisa Yan, CS109, 2020
Oishi Banerjee
5
Stanford Co-term
- B.A. in Classics (Latin and Greek)
- M.S. in Computer Science (Artificial
Intelligence)
- Currently conducting medical AI research
- Fun fact: I sing opera in my spare time!
![Page 6: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/6.jpg)
Lisa Yan, CS109, 2020
Cooper Raterink
6
Stanford Master’s Student
- B.S. in Electrical and Computer Engineering
at UT Austin
- M.S. in Computer Science (Artificial
Intelligence)
- I’ve done research on AI & Sustainability
- Interested in Humane AI
- Fun fact
![Page 7: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/7.jpg)
Lisa Yan, CS109, 2020
What makes this quarter important
We are seeing a huge surge in statistics, predictions, and probabilistic models shared through global news, governing bodies, and social media.
7
Global cases of COVID-19 as of April 1st (JHU)https://coronavirus.jhu.edu/map.html
Predicted Hospital
Resource Use in United
States (IHME)https://covid19.healthdata.org
/projections
Cases per 100K in NY, NJ,
and CA counties (my dad)https://app.flourish.studio/login
![Page 8: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/8.jpg)
Lisa Yan, CS109, 2020
What makes this quarter important
We are seeing a huge surge in statistics, predictions, and probabilistic models shared through global news, governing bodies, and social media.
The challenge of delivering Stanford-class education online reflects our university’s commitment to fostering a diverse body of students.
8
![Page 9: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/9.jpg)
Lisa Yan, CS109, 2020
What makes this quarter important
We are seeing a huge surge in statistics, predictions, and probabilistic models shared through global news, governing bodies, and social media.
The challenge of delivering Stanford-class education online reflects our university’s commitment to fostering a diverse body of students.
The technological and social innovation we develop during this time will strongly impact how we approach truly world-class education.
9
![Page 10: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/10.jpg)
Lisa Yan, CS109, 2020
What makes this quarter important
We are seeing a huge surge in statistics, predictions, and probabilistic models shared through global news, governing bodies, and social media.
The challenge of delivering Stanford-class education online reflects our university’s commitment to fostering a diverse body of students.
The technological and social innovation we develop during this time will strongly impact how we approach truly world-class education.
10
To teach you how probability applies to real life
To help you foster and maintain human connections throughout this course
Our goals this quarter(at minimum)
![Page 11: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/11.jpg)
11
that being said…
![Page 12: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/12.jpg)
Lisa Yan, CS109, 2020
What makes this quarter important
These are extraordinary circumstances.
The teaching staff and I realizethat this quarter cannot replacean in-person, on-campus experience.Your diverse backgrounds amplifythis difference.
All our situations may change.
We are committed to working through this version of this course together and adapting as a class and as a community. We welcome your thoughts.
Thank you in advance for being patient with necessary changes to make this educational experience fulfilling, meaningful, and equitable.
12
0%
10%
20%
30%
40%
50%
60%
Not very conducive Very conducive
Learning environment
0%
10%
20%
30%
40%
50%
60%
Strongly disagree Strongly agree
Reliable access to
internet
![Page 13: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/13.jpg)
13
What about you?
…first, some Breakout Room guidelines...
![Page 14: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/14.jpg)
Lisa Yan, CS109, 2020
Lecture with
• Turn on your camera if you are able, mute your mic in the big room
• Virtual backgrounds are encouraged (classroom-appropriate)
Breakout Rooms for meeting your classmates◦ Just like sitting next to someone new
We will use Ed instead of Zoom chat◦ Like raising your hand in the classroom, except with a lower barrier to entry
◦ You can upvote your classmates’ posts
◦ Persistent copy: Teaching staff and I can answer questions during and after lecture
◦ Better threading/reply support, copy/paste, LaTeX math mode, emojis
14
Join discussion forum here: https://us.edstem.org/join/nhECh5
Today’s discussion thread: https://us.edstem.org/courses/667/discussion/79610
![Page 15: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/15.jpg)
Post or upvote some thoughts on Ed:
• What is something you hope to get out of this quarter?
• What are you worried about this quarter?
• What are your hopes for CS109, given that it is online?
Join discussion forum here: https://us.edstem.org/join/nhECh5
Today’s discussion thread: https://us.edstem.org/courses/667/discussion/79610
By yourself
15
🤔
![Page 16: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/16.jpg)
Breakout Rooms
Introduce yourself! (name, major, year)
Then check out the responses your classmates wrote, and comment/discuss!
• What is something you hope to get out of this quarter?
• What are you worried about this quarter?
• What are your hopes for CS109, given that it is online?
Join discussion forum here: https://us.edstem.org/join/nhECh5
Today’s discussion thread: https://us.edstem.org/courses/667/discussion/79610
16
🤔
![Page 17: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/17.jpg)
Course mechanics
17
![Page 18: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/18.jpg)
Lisa Yan, CS109, 2020
Course mechanics (light version)
• For more info, read the Administrivia handout and FAQ
• Course website:
http://cs109.stanford.edu/
• Canvas (only for posting videos/recordings)
18
![Page 19: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/19.jpg)
Lisa Yan, CS109, 2020
Prerequisites
19
CS106B/X
ProgrammingRecursionHash tablesBinary trees
CS103(co-requisite OK)
Proofs (induction)Set theoryMath maturity
MATH 51/CME 100
Multivariate differentiationMultivariate integrationBasic facility with linear
algebra (vectors)
Important!
![Page 20: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/20.jpg)
Lisa Yan, CS109, 2020
How many units should I take?
20
5 Units
3 Units
-or-
4 Units
Are you an
undergrad?
Do you wantto take CS109 for
fewer units?
Start Here
Average about 10 hours / week for assignments
Yes
No
No
Yes
515
![Page 21: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/21.jpg)
Lisa Yan, CS109, 2020
Staff contact
• Discussion forum: https://us.edstem.org/courses/667/discussion/
• Staff email: [email protected]
• Office Hours start Tuesday◦ Find the schedule on the website
• Contact mailing list for course level issues, extensions, etc.
21
![Page 22: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/22.jpg)
Lisa Yan, CS109, 2020
Lecture format
22
”Probability is a number
between 0 and 1”
In-person, discussion-oriented lecture
MWF 1:30pm PT
(<110min)
Short pre-recorded lecture
(several 5-10 min videos)
“What is the probability
that you get exactly 3
heads in 5 coin flips?”
”What is the definition of
probability? (select one)”
Concept check quiz on Gradescope
(submit infinitely many times,
maybe on-time bonus)
![Page 23: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/23.jpg)
Lisa Yan, CS109, 2020
Where you learn
Pre-recorded lectures
Live lectures recordings posted to Canvas
Optional Discussion Section starting Week 1
Lecture notes on website
Textbook readings optional
Problem Sets
Quizzes
23
![Page 24: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/24.jpg)
Lisa Yan, CS109, 2020
Class breakdown
60% 6 Problem Sets
25% Quizzes
15% Participation
24
• Concept checks on pre-recorded material
• Take-home format, more details later
• Monday, July 20
• Friday, August 14
![Page 25: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/25.jpg)
Lisa Yan, CS109, 2020
60% Problem Sets
Late Policy +5% for on-time submission+0% bonus for 1 class day late-20% for 2 class days late-40% for 3 class days (1 week) late
Optional but encouraged, tutorial online
More information coming soon
25
![Page 26: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/26.jpg)
Lisa Yan, CS109, 2020
Quizzes, Participation
25% Quizzes
• 12.5% each
• Around 2 hours of individual work
• 24-hour take-home window
15% Participation
• (15%) Concept checks: based on pre-lecture recordings
• We recommend you complete concept checks before lecture
• Unlimited submissions/autograded until last day of classes, August 13
26
![Page 27: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/27.jpg)
Lisa Yan, CS109, 2020
Permitted
• Talk to the course staff
• Talk with classmates(cite collaboration)
• Look up general material online
NOT permitted:
• Copy answers:
from classmates
from former studentsfrom previous quarters
• Copy answers from the internetBesides, these are usually incorrect
27
Stanford Honor Code
![Page 28: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/28.jpg)
Why you should take CS109
28
![Page 29: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/29.jpg)
Lisa Yan, CS109, 2020
Traditional View of Probability
29
![Page 30: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/30.jpg)
Lisa Yan, CS109, 2020
CS view of probability
30
http://www.site.comhttp://www.site.comhttp://www.site.com
![Page 31: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/31.jpg)
31
Machine Learning= Machine
+ Probability + Data
(compute power)
![Page 32: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/32.jpg)
Lisa Yan, CS109, 2020
Machine Learning Algorithm
32
Build a
probabilistic
model
DataDo one
thing
![Page 33: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/33.jpg)
Lisa Yan, CS109, 2020
Classification
33
![Page 34: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/34.jpg)
Lisa Yan, CS109, 2020
Where is this useful?
A machine learning algorithm performs better than the best dermatologists.
Developed in 2017 at Stanford.
34
Esteva, Andre, et al. "Dermatologist-level classification of skin cancer with deep neural networks."
Nature 542.7639 (2017): 115-118.
![Page 35: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/35.jpg)
Lisa Yan, CS109, 2020
Image tagging
35
![Page 36: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/36.jpg)
Lisa Yan, CS109, 2020
Decision-making: The last remaining board game
36
![Page 37: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/37.jpg)
Lisa Yan, CS109, 2020
Augmented Reality Machine Translation
37
Automatic machine translation on Google Translate
![Page 38: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/38.jpg)
Lisa Yan, CS109, 2020
Style transfer
38
![Page 39: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/39.jpg)
Lisa Yan, CS109, 2020
Content ranking and grouping
39
![Page 40: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/40.jpg)
Lisa Yan, CS109, 2020
Probability at your fingertips
40
![Page 41: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/41.jpg)
Lisa Yan, CS109, 2020
Voice assistants
41
![Page 42: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/42.jpg)
42
Probability is more than just machine learning.
![Page 43: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/43.jpg)
Lisa Yan, CS109, 2020
Probability and medicine
43
Predicted Hospital
Resource Use in United
States (IHME)https://covid19.healthdata.org
/projections
How do COVID-19 testing
rates in a region correlate
with the actual spread of the
disease?
![Page 44: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/44.jpg)
Lisa Yan, CS109, 2020
Probability and climate
44
![Page 45: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/45.jpg)
Lisa Yan, CS109, 2020
Probabilistic analysis of algorithms
45
![Page 46: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/46.jpg)
Lisa Yan, CS109, 2020
Probability for good
How do we identify systemic biases in our data and incorporatehuman judgment into our probabilistic models?
46
Algorithms of Oppression,
Safiya Umoja Noble. 2018
![Page 47: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/47.jpg)
Lisa Yan, CS109, 2020
Probability and philosophy
47
![Page 48: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/48.jpg)
48
We’ll get there!
![Page 49: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/49.jpg)
49
Probability is not always intuitive.
![Page 50: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/50.jpg)
Lisa Yan, CS109, 2020
Disease testing
A patient takes a virus test that returns positive.
What is the probability that they have the virus?
• 0.03% of people have the virus
• Test has 99% positive rate for people with the virus
• Test has 7% positive rate for people without the virus
Correct answer: 42/10000 (0.42%)
50
![Page 51: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/51.jpg)
51
Probability = Important+ Needs Studying
![Page 52: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/52.jpg)
Counting I
52
![Page 53: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/53.jpg)
Lisa Yan, CS109, 2020
What is Counting?
An experimentin probability:
Counting: How many possible outcomes can occur fromperforming this experiment?
53
OutcomeExperiment
![Page 54: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/54.jpg)
Lisa Yan, CS109, 2020
What is Counting?
54
6
36
{1, 2, 3,
4, 5, 6}Roll even only
3 {2, 4, 6}
{(1, 1) , (1, 2), (1, 3), (1, 4), (1, 5), (1, 6),
(2, 1) , (2, 2), (2, 3), (2, 4), (2, 5), (2, 6),
(3, 1) , (3, 2), (3, 3), (3, 4), (3, 5), (3, 6),
(4, 1) , (4, 2), (4, 3), (4, 4), (4, 5), (4, 6),
(5, 1) , (5, 2), (5, 3), (5, 4), (5, 5), (5, 6),
(6, 1) , (6, 2), (6, 3), (6, 4), (6, 5), (6, 6)}
Roll
Roll
![Page 55: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/55.jpg)
Lisa Yan, CS109, 2020
Sum Rule of Counting
If the outcome of an experiment can be either from
Set 𝐴, where 𝐴 = 𝑚,
or Set 𝐵, where 𝐵 = 𝑛,
where 𝐴 ∩ 𝐵 = ∅ ,
Then the number of outcomes of the experiment is
𝐴 + 𝐵 = 𝑚 + 𝑛.
55
One experiment
A
B
![Page 56: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/56.jpg)
Lisa Yan, CS109, 2020
Product Rule of Counting
If an experiment has two parts, where
The first part’s outcomes are from Set 𝐴, where 𝐴 = 𝑚, and the second part’s outcomes are from Set 𝐵, where 𝐵 = 𝑛regardless of part one’s outcomes,
Then the number of outcomes of the experiment is
𝐴 𝐵 = 𝑚𝑛.
56
Two-step experiment
A B
![Page 57: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/57.jpg)
Lisa Yan, CS109, 2020
Let’s try it out
Sum Rule, Product Rule, or something else? How many outcomes?
1. Video streaming application• Your application has distributed
servers in 2 locations (SJ: 100, Boston: 50).
• If a web request is routed to a server,how large is the set of servers it can get routed to?
2. Dice• How many possible outcomes are
there from rolling two 6-sided dice?
3. Strings• How many different orderings of letters
are possible for the string BOBA?
57
San Jose100 servers Boston
50 servers
BOBA,ABOB,OBBA…
🤔
Think, pair, and we’ll come back as a group. Post any questions here:
https://us.edstem.org/courses/109/discussion/24490
![Page 58: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/58.jpg)
Lisa Yan, CS109, 2020
Let’s try it out
Sum Rule, Product Rule, or something else? How many outcomes?
1. Video streaming application• Your application has distributed
servers in 2 locations (SJ: 100, Boston: 50).
• If a web request is routed to a server,how large is the set of servers it can get routed to?
2. Dice• How many possible outcomes are
there from rolling two 6-sided dice?
3. Strings• How many different orderings of letters
are possible for the string BOBA?
58
A = {100 servers in San Jose}
B = {50 servers in Boston}
|A| + |B| = 150
A = {1, 2, 3, 4, 5, 6 on 1st die}
B = {1, 2, 3, 4, 5, 6 on 2nd die}
|A||B| = 6 · 6 = 36
First letter's options = {B, O, A}
Second letter’s options = ???
Final answer is 12.
See the recorded videos for
why…
![Page 59: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/59.jpg)
Lisa Yan, CS109, 2020
For next time
• Watch pre-recorded lectures for Wednesday 6/24 posted on the website schedule
◦ You’ll see something like: “Watch: 1_all, 2_all,” indicating to watch videos from the 1st and 2nd series on Canvas
• Complete one concept check that covers both lecturesto be posted this afternoon PT
http://cs109.stanford.edu/
59
✏️
![Page 60: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/60.jpg)
Thanks for listening!
60
![Page 61: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/61.jpg)
Counting I
61
I
Gradescope quiz, blank slide deck, etc.
(Available Monday 4/6 evening PT)
http://cs109.stanford.edu/
01b_counting_ii
![Page 62: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/62.jpg)
Lisa Yan, CS109, 2020 62
recipes
![Page 63: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/63.jpg)
Lisa Yan, CS109, 2020
Inclusion-Exclusion Principle
If the outcome of an experiment can be either from
Set 𝐴 or set 𝐵,
where 𝐴 and 𝐵 may overlap,
Then the total number of outcomes of the experiment is
𝐴 ∪ 𝐵 = 𝐴 + 𝐵 − |𝐴 ∩ 𝐵|.
63
Sum Rule of Counting:
A special case
One experiment
A
B only
![Page 64: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/64.jpg)
Lisa Yan, CS109, 2020
Transmitting bytes over a network
An 8-bit string is sent over a network.
• The receiver only accepts strings thateither start with 01 or end with 10.
How many 8-bit strings will the receiver accept?
64
byte (8 bits)
01001100
Define
𝐴 : 8-bit strings
starting with 01
𝐵 : 8-bit strings
ending with 10
🤔
![Page 65: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/65.jpg)
Lisa Yan, CS109, 2020
Transmitting bytes over a network
An 8-bit string is sent over a network.
• The receiver only accepts strings thateither start with 01 or end with 10.
How many 8-bit strings will the receiver accept?
65
byte (8 bits)
01001100
Define
𝐴 : 8-bit strings
starting with 01
𝐵 : 8-bit strings
ending with 10
![Page 66: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/66.jpg)
Lisa Yan, CS109, 2020
General Principle of Counting
If an experiment has 𝑟 steps, such that
Step 𝑖 has 𝑛𝑖 outcomes for all 𝑖 = 1,… , 𝑟,
Then the number of outcomes of the experiment is
66
𝑛1 × 𝑛2 × ⋯ × 𝑛𝑟 =ෑ
𝑖=1
𝑟
𝑛𝑖 .
Product Rule of Counting:
A special case
Multi-step
experiment
1 2 …
![Page 67: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/67.jpg)
Lisa Yan, CS109, 2020
License plates
How many CA license plates are possible if…
67
(pre-1982)
(present day)🤔
![Page 68: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/68.jpg)
Lisa Yan, CS109, 2020
License plates
How many CA license plates are possible if…
68
(pre-1982)
(present day)
![Page 69: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/69.jpg)
Pigeonhole Principle
69
01c_pigeonhole
Gradescope quiz, blank slide deck, etc.
http://cs109.stanford.edu/
![Page 70: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/70.jpg)
Lisa Yan, CS109, 2020
Floors and ceilings
Check it out:
70
Floor function
𝑥
The largest integer ≤ 𝑥
Ceiling function
𝑥
The smallest integer ≥ 𝑥
1/2
1/2
2.9
2.9
8.0
8.0
−1/2
−1/2
![Page 71: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/71.jpg)
Lisa Yan, CS109, 2020
Pigeonhole Principle
For positive integers 𝑚 and 𝑛,
if 𝑚 objects are placed in 𝑛 buckets,
then at least one bucket must containat least 𝑚/𝑛 objects.
Example:
71
Pigeons in holes 21st century pigeons
At least one pigeonhole must
contain 𝑚/𝑛 = 2 pigeons.
𝑚 objects = 10 pigeons
𝑛 buckets = 9 pigeonholes
Bounds: an important part of CS109
![Page 72: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/72.jpg)
Lisa Yan, CS109, 2020
Balls and urns
72
𝑟 urns
(buckets)
𝑛 balls
![Page 73: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/73.jpg)
Lisa Yan, CS109, 2020
Balls and urns Hash Tables and strings
Consider a hash table with 100 buckets.
950 strings are hashed and added to the table.
1. Is it guaranteed that at least onebucket contains at least 10 entries?
2. Is it guaranteed that at least onebucket contains at least 11 entries?
3. Is it possible to have a bucket with no entries?
73
🤔
![Page 74: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/74.jpg)
Lisa Yan, CS109, 2020
Balls and urns Hash Tables and strings
Consider a hash table with 100 buckets.
950 strings are hashed and added to the table.
1. Is it guaranteed that at least onebucket contains at least 10 entries?
2. Is it guaranteed that at least onebucket contains at least 11 entries?
3. Is it possible to have a bucket with no entries?
74
𝑛 = 100𝑚 = 950
Yes
No
Sure
![Page 75: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/75.jpg)
Permutations I
75
01d_permutations
Gradescope quiz, blank slide deck, etc.
http://cs109.stanford.edu/
![Page 76: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/76.jpg)
Lisa Yan, CS109, 2020
Unique 6-digit passcodes with six smudges
76
How many unique 6-digit passcodes are possible if a
phone password uses each of six distinct numbers?
![Page 77: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/77.jpg)
Lisa Yan, CS109, 2020
Sort 𝑛 indistinct objects
77
![Page 78: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/78.jpg)
Lisa Yan, CS109, 2020
Sort 𝑛 distinct objects
78
![Page 79: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/79.jpg)
Lisa Yan, CS109, 2020
Sort 𝑛 distinct objects
79
Steps:
1. Choose 1st can 5 options
2. Choose 2nd can 4 options
…
5. Choose 5th can 1 option
Total = 5 × 4 × 3 × 2 × 1
= 120
1st 2nd 3rd 4th 5th
![Page 80: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/80.jpg)
Lisa Yan, CS109, 2020
Permutations
A permutation is an ordered arrangement of objects.
The number of unique orderings (permutations) of 𝑛 distinct objects is𝑛! = 𝑛 × 𝑛 − 1 × 𝑛 − 2 ×⋯ × 2 × 1.
80
![Page 81: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/81.jpg)
Lisa Yan, CS109, 2020
Unique 6-digit passcodes with six smudges
81
Total = 6!
= 720 passcodes
How many unique 6-digit passcodes are possible if a
phone password uses each of six distinct numbers?
![Page 82: CS109: Probability for Computer Scientists”Probability is a number between 0 and 1” In-person, discussion-oriented lecture MWF 1:30pm PT (](https://reader030.fdocuments.net/reader030/viewer/2022040309/5f28b8b3a2f7bf549f1d9348/html5/thumbnails/82.jpg)
Lisa Yan, CS109, 2020
Unique 6-digit passcodes with five smudges
82
How many unique 6-digit passcodes are possible if a
phone password uses each of five distinct numbers?