Basic probability
Events • An event is something that can happen. • An atomic event is not composed of others. • Each atomic event x has an associated probability P[x] ∈ [0,1]. • The sum of the probabilities of all atomic events is 1. X P [ x ] = 1 x is atomic event • We consider only finite or countably infinite sets of atomic events. • Example: throwing a dice: • atomic events = {1, 2, 3, 4, 5, 6} • If it is a fair dice then: P[1] = P[2] = P[3] = P[4] = P[5] = P[6] =1/6. • If it is an unfair dice then we can have di ff erent probabilities for the di ff erent events. Fx: • P[1] = P[2] = 1/3, P[3] = P[4] = P[5] = 1/18, P[6] =1/6 � 11
Random variables • A random variable is an entity that can assume di ff erent values. • The values are selected “randomly”; i.e., the process is governed by a probability distribution. • Examples: Let X be the random variable “number shown by dice”. • X can take the values 1, 2, 3, 4, 5, 6. • If it is a fair dice then the probability that X = 1 is 1/6: • P[X=1] =1/6. • P[X=2] =1/6. • … � 12
Random variables • A random variable is an entity that can assume di ff erent values. • The values are selected “randomly”; i.e., the process is governed by a probability distribution. • Examples: • The number shown by a dice: • X random variable “number shown by dice”. • X can take the values 1, 2, 3, 4, 5, 6. • If it is a fair dice then the probability that X = 1 is 1/6: • P[X=1] = P[X=2] = P[X=3] = P[X=4] = P[X=5] = P[X=6] =1/6. • The distance of two coins dropped on the floor. • The running time of a randomized algorithm. � X
Expected values • Let X be a random variable with values in {x 1 ,…x n }, where x i are numbers. • Let p i = P[X = x i ] be the probability that X assumes value x i . • The expected value (expectation) of X is defined as n X E [ X ] = x i · p i i =1 • The expectation is the theoretical average. � 13
Example: a fair dice • Let X be the random variable “number shown by the dice”. • Atomic events: {1, 2, 3, 4, 5, 6} • Probabilities: P[1] = ··· = P[6] = 1/6 • Composed event: Even = {2, 4, 6} • Composed event: ge4 = {4, 5, 6} • Expectation: E [ X ] = 1 ⋅ P [ X = 1] + 2 ⋅ P [ X = 2] + 3 ⋅ P [ X = 3] + 4 ⋅ P [ X = 4] + 5 ⋅ P [ X = 5] + 6 ⋅ P [ X = 6] = 1 ⋅ 1 6 + 2 ⋅ 1 6 + 3 ⋅ 1 6 + 4 ⋅ 1 6 + 5 ⋅ 1 6 + 6 ⋅ 1 6 = (1 + 2 + 3 + 4 + 5 + 6) ⋅ 1 6 n = 3.5 X E [ X ] = x i · p i i =1 � 14
Example: a loaded dice • Let X be the random variable “number shown by the dice”. • Atomic events: 1, 2, 3, 4, 5, 6 • Probabilities: 0.1, 0.1, 0.1, 0.3, 0.2, 0.2 • Expectation E[X] = 1 · 0.1 + 2 · 0.1 + 3 · 0.1 + 4 · 0.3 + 5 · 0.2 + 6 · 0.2 = 4.0 n X E [ X ] = x i · p i i =1 � 15
Expectation • If we repeatedly perform independent trials of an experiment, each of which succeeds with probability p > 0, then the expected number of trials we need to perform until the first succes is 1/p. • Linearity of expectation: For two random variables X and Y we have E[X+Y] = E[X] + E[Y]. � 16
Example: Using random variables for counting • We have a fair dice that we toss 6 times. • Let X be random variabel “the number of times we get a 1”. • Let X 1 be a random variable that is 1 if we get 1 in the first throw and 0 otherwise. • Let X 2 be a random variable that is 1 if we get 1 in the second throw and 0 otherwise. • …. X i = { we get a 1 in the i th throw 1 • That is otherwise 0 • X i is called an indicator variable. • We have • X = X 1 + X 2 + X 3 + X 4 + X 5 + X 6 • E[X] = E[X 1 ] + E[X 2 ] + E[X 3 ] + E[X 4 ] + E[X 5 ] + E[X 6 ] • E[X i ] = 1 · Pr[X i = 1] + 0 · Pr[X i = 0] = Pr[X i = 1] = 1/6 • E[X] = 1/6 + 1/6 + 1/6 + 1/6 + 1/6 +1/6 = 6/6 = 1.
Rules for Probabilities • Let A and B be events. • If A and B are independent then • P[A ∧ B] = P[A] · P[B] • If A and B are disjoint then • P[A ∨ B] = P[A] + P[B] � 18
Independence example • A dice is tossed twice. • Let the random variable X 1 be the result of first throw. • Let the random variable X 2 be the result of second throw. • Events: A = (X 1 = 2) and B = (X 2 = 5) • P[A] = 1/6 and P[B] = 1/6 • P[A ∧ B] = 1/36 = 1/6·1/6 = P[A] · P[B] � 19
Non-independent example • A dice is tossed once. • Event A = Even = {2, 4, 6}: P[A] = 1/2 • Event B = ge4 = {4, 5, 6}: P[B] = 1/2 • A ∧ B = {4, 6} • P[A ∧ B] = 1/3 ≠ 1/4 = P[A] · P[B] � 20
Disjoint example • A dice is tossed once. • Event A = Div3 = {3, 6}: P[A] = 1/3 • Event B = le2 = {1, 2}: P[B] = 1/3 • A ∨ B = {1, 2, 3, 6} • P[A ∨ B] = 2/3 = 1/3 + 1/3 = P[A] + P[B] � 21
Recommend
More recommend