Lecture 1: Probability and Counting
Ziyu Shao School of Information Science and Technology ShanghaiTech University September 21, 2018 Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 1 / 47Lecture 1: Probability and Counting Ziyu Shao School of Information - - PowerPoint PPT Presentation
Lecture 1: Probability and Counting Ziyu Shao School of Information - - PowerPoint PPT Presentation
Lecture 1: Probability and Counting Ziyu Shao School of Information Science and Technology ShanghaiTech University September 21, 2018 Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 1 / 47 Outline Good Books
Outline
1 Good Books for Linear Algebra 2 Naive Definition of Probability 3 Counting 4 Definition of Probability Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 2 / 47Outline
1 Good Books for Linear Algebra 2 Naive Definition of Probability 3 Counting 4 Definition of Probability Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 3 / 47Introduction to Linear Algebra
Gilbert Strang Introduction to Linear Algebra (5th Edition) Wellesley-Cambridge Press, 2016. http://math.mit.edu/ ~gs/linearalgebra/ Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 4 / 47Coding The Matrix
Philip N. Klein Coding The Matrix: Linear Algebra Through Computer Science Applications Newtonian Press, 2013 codingthematrix.com Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 5 / 47Introduction to Applied Linear Algebra
Stephen Boyd & Lieven Vandenberghe Introduction to Applied Linear Algebra: Vectors, Matrices, and Least Squares Cambridge University Press, 2018. http://vmls-book. stanford.edu/ Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 6 / 47Practical Linear Algebra
Gerald Farin & Dianne Hansford Practical Linear Algebra: A Geometry Toolbox (3rd Edition) CRC Press, 2014. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 7 / 47Linear Algebra Done Right
Sheldon Axler Linear Algebra Done Right (3rd Edition) Springer, 2015. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 8 / 47No Bullshit Guide to Linear Algebra
Ivan Savov No Bullshit Guide to Linear Algebra (2nd Edition) Minireference Co., 2017. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 9 / 47Outline
1 Good Books for Linear Algebra 2 Naive Definition of Probability 3 Counting 4 Definition of Probability Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 10 / 47Set
A set is a collection of objects. Given two sets A, B, key concepts include empty set: ; A is a subset of B: A ✓ B union of A and B: A [ B intersection of A and B: A \ B complement of A: Ac De Morgan’s laws: (A [ B)c = Ac \ Bc (A \ B)c = Ac [ Bc Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 11 / 47=
me
- ~
Venn Diagram
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 12 / 47Sample Space & Event
The sample space S of an experiment: the set of all possible- utcomes of the experiment.
⇒
ef1,2,...q}_C)
_- A={ 1. 2,3>4,5 }- I
67
8 9Example: Coin flips
A coin is flipped 10 times. Writing Heads as 1 and Tails as 0. Then An outcome is a sequence (s1, s2, . . . , s10) with sj 2 {0, 1}. The sample space: the set of all such sequences. Aj: the event that the jth flip is Head. B: the event that at least one flip was Head. (B = S10 j=1 Aj) C: the event that all the flips were Heads. (C = \10 j=1Aj) D: the event that there were at least two consecutive Heads. (D = S9 j=1(Aj \ Aj+1)) Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 14 / 471,111k¥
- D
- ~
- mm
- ÷
Translation Between English & Sets
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 15 / 47÷
- =
- r
Naive Definition of Probability
Assumption 1: finite sample space Assumption 2: all outcomes occur equally likely Definition Let A be an event for an experiment with a finite sample space S. The naive probability of A is Pnaive(A) = |A| |S| = number of outcomes favorable to A total number of outcomes in S . Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 16 / 47Outline
1 Good Books for Linear Algebra 2 Naive Definition of Probability 3 Counting 4 Definition of Probability Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 17 / 47Multiplication Rule
You buy an ice cream cone with several choices: cone: cake or waffle flavor: chocolate, vanilla, or strawberry Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 18 / 47- ==
Multiplication Rule in General
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 19 / 47Sampling With Replacement
Theorem Consider n objects and making k choices from them, one at a time with replacement (i.e., choosing a certain object does not preclude it from being chosen again). Then there are nk possible outcomes. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 20 / 47.
# ' ×*L× . ...Ik
}=n@- .
Sampling Without Replacement
Theorem Consider n objects and making k choices from them, one at a time without replacement (i.e., choosing a certain object preclude it from being chosen again). Then there are n(n 1) · · · (n k + 1) possible- utcomes for k n (and 0 possibilities for k > n).
.
I ° # I n hen # 2 nt- ¥n
=
Example: Birthday Problem
There are k people in a room. Assume each person’s birthday is equally likely to be any of the 365 days of the year (we exclude February 29), and that people’s birthdays are independent (we assume there are no twins in the room). What is the probability that two or more people in the group have the same birthday? Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 22 / 47- .
Solution of Birthday Problem
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 23 / 47 O k > 365 10=1- 2
- '
i"ii=
# ofugs assign birthdays to k . . ( 365 , k , without replacer . ) = 1 .=
@ 65 . k , replacement ) 365.364 . . .- ( 365
- KTH
- 365£
Solution of Birthday Problem
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 24 / 47 l : I : 1 I 23Generalized Birthday Problem
Each of k people has a random number (“birthday”) drawn from n values (“days”). If the probability that at least two people have the same number is 50%, then k ⇡ 1.18pn. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 25 / 47 A = " 32 . ... man " .&@ 2@
. . .- i.
- i )
- ktl )
- =p
- sample
p=x
- mm
.
Fit etn.EE . . . EE ' = f- e- d- CHZT . .tk . i ) PCA 1=0.5 be =L ' e- £i#
,.e_a@
- easy
Application: Hash Table
A commonly used data structure for fast information retrieval Example: store people’s name. For each people x, a hash function h is computed. h(x): the location that will be used to store x0s name. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 26 / 47- ÷
- ,
Hash Collision
Collision: x 6= y, but h(x) = h(y) ( 1 locations has 2 names stored there) Given k people (different names) and n locations, what is the probability of occurrence of hash collision? Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 27 / 47÷
Solution of Hash Collision
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 28 / 47Binomial Coefficient
Definition For any nonnegative integers k and n, the binomial coefficient n k- ,
C!
no
ncn-D.gg?h#
Example: Bose-Einstein
How many ways are there to choose k times from a set of n objects with replacement, if order doesn’t matter (we only care about how many times each object was chosen, not the order in which they were chosen)? Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 30 / 471,2€
Xj : jthobgaes C # . chosen ) ( ¥ '}n°)
Xitxzt . . . + Xn =k- nonnegative
'nteg÷
- =L
Equivalent Problem
Theorem There are r1 n1- distinct positive integer-valued vectors
- t##
- 6
!
. : . 1 ' .0 . . . . O a a a . f- ( spaces . =- mum
Bose-Einstein Counting
Theorem There are n+k1 n1- distinct nonnegative integer-valued vectors
- XI
T.ci#Ye31&Y,-yz+..iYn=kt=
positive integersand
Example: Multinomial Expansion
How many terms are there in the multinomial expansion of (x1 + x2 + . . . + xr)n? Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 33 / 47 ( Xntxn )2 =×±?tziE¥i+xI . a For each item , ( Xi"xin?..xT)
- *
- Nitnzt
cnn.jcnnmj.i.FI#=N!n
! ni !n2 ! ... nh 3 ( Xitxzt . .tXn , " = £ T.hr?Xin'Xzn2...xrnrni.nL...nrZ0n,+nrttnr=n # of <⇒ ni-nu.mn#nonhegatueintegensow+._("F#.
Summary of Counting
Choose k objects out of n objects, the number of possible ways: Order Matters Order Not Matter with replacement nk n+k1 k- without replacement
- Ziyu Shao (ShanghaiTech)
TO
08
Outline
1 Good Books for Linear Algebra 2 Naive Definition of Probability 3 Counting 4 Definition of Probability Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 35 / 47General Definition of Probability
Definition A probability space consists of a sample space S and a probability function P which takes an event A ✓ S as input and returns P(A), a real number between 0 and 1, as output. The function P must satisfy the following axioms: 1 P(;) = 0, P(S) = 1. 2 If A1, A2, . . . are disjoint events, then P( 1 [ j=1 Aj) = 1 X j=1 P(Aj) (Saying that these events are disjoint means that they are mutually exclusive: Ai \ Aj = ; for i 6= j. Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 36 / 47 =- n
=
=
- Countableinfiniter
Interpretation of Probability
Complementary views: The frequentist view: probability represents a long-run frequency- ver a large number of repetitions of an experiment.
- ver and over.
- ver again.
÷
Properties of Probability
Probability has the following properties, for any events A and B: 1 P(Ac) = 1 P(A). 2 If A ✓ B, then P(A) P(B). 3 P(A S B) = P(A) + P(B) P(A \ B). Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 38 / 47 EO . O PCEUAI ) =p(s)=| 2€0
B=A0CBnA= PLBKPCA ) t PCBNAC ) PCAHPLAC ) =l⇐ ZPLA )- ⇐
- spotting
€,*@!o
" a " "IEia5YYYI¥→
, ✓ p(BnA9=PcB1-PCAnB=Example: Bonferroni’s Inequality
Theorem For any n events A1, . . . , An, we have P(A1 \ A2 \ · · · \ An) P(A1) + P(A2) + · · · + P(An) (n 1). Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 39 / 47 Lt 's aus F- € w n 't ipts
path ✓ 2 n=2 PCAinAz)>PLAittPlA= ✓ L⇒ 1 3 P(Ai)tPLA2)-PLAinA= PCA.UA#:
Tamai ) =p( Fi 0¥ . . .uEn )÷
tend
¥n¥¥
.it?ItEiIIII.n.J
= n- [
- 1
↳
Example: Boole’s Inequality
Theorem For any events A1, A2, . . ., we have P( 1 [ i=1 Ai) 1 X i=1 P(Ai). Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 40 / 47¥ AL
⇒ Sequences of disjoint Sets . Al U As = A , U ( Az n AT ) ÷ .And
U Az = Aid U ( Az n AIID = Al U ( Az n AT ) U ( A 3 nAt
A i U.A.su . . . U An = A , U ( Azn AT ) U . . . . (1 CAN NATE . , )died
. . . . p ( Ia ) = P ( I AIEA) = ftp.#InTadIDeTIPas .Inclusion-Exclusion Formula
For any events A1, . . . , An: P( n [ i=1 Ai) = X i P(Ai) X i<j P(Ai \ Aj) + X i<j<k P(Ai \ Aj \ Ak) + . . . + (1)n+1P(A1 \ · · · \ An). Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 41 / 47- =
it
'Example: De Montmort’s Matching Problem
Consider a well-shuffled deck of n cards, labeled 1 through n. You flip- ver the cards one by one, saying the numbers 1 through n as you do
- so. You win the game if, at some point, the number you say aloud is
=
Solution to De Montmort’s Matching Problem
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 43 / 47 A ; = " c # Card in the deck has label : " .=p
( A,UAz..vAn)_ Winton E*=t×+z¥ ....ee/,nnIPlAi)=+nkc=.#b=tn
]
+ " 'Yana
,,=÷e÷⇒
aunless
.IS?iiIlIYPlAinAInAk)=#h=ai
, , = 1- et :- bitten 'Az
=n!E¥InI÷EEI¥I÷¥I÷I¥y÷Ii::I¥ta÷*TDI
Summary 1: Events & Numbers
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 44 / 4700
Summary 2: Probability Space
Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 45 / 47- 8 ?
Summary 3: The Role of Probability & Statistics
A framework for analyzing phenomena with uncertain outcomes: Rules for consistent reasoning Used for predictions and decisions Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 46 / 47⇐
Reading Assignment
Next lecture we will study conditional probability. Please read corresponding chapters in textbooks: Chapter 2 of BH Chapter 1 of BT Ziyu Shao (ShanghaiTech) Lecture 1: Probability and Counting September 21, 2018 47 / 47KG
.g-