CSCE 411 Lecture 23

From Notes
Jump to navigation Jump to search
Lecture Slides

« previous | Monday, October 22, 2012 | next »

No lecture last Friday due to bomb threat.

Randomized Algorithms

Verifying Polynomial Identity

def verify_polynomial_identity f, g
  d = [f.degree, g.degree].max
  r = (1..100*d).to_a.sample
  f(r) == g(r)
end

The alogorithm reports that F(r) and G(r) are the same although they are different iff r is a root of the polynomial F(x)G(x).

A polynomial of degree d has exactly d roots, so choosing from [1..100d] gives 1/100 chance for error.

We could reduce this even further by choosing a larger range of integers, but no matter how large, there will always be a small chance for error.

We could also run the algorithm k times, so the failure probability of failure for k independent events

Pr[E1E2Ek]=i=1kPr[Ei]i=1kd100d=(1100)k

Random Variables

More probability theory. (See :Category:STAT 211-507→)


Let F be a σ-algebra over a sample space Ω. A random variable X is a function ΩR such that {zΩ|X(z)x} is an event in F for each x in R.

We write Xx for this event.

Allows us to describe events as preimages.

Examples

  1. Let X be the random variable denoting the sum of face values of a pair of dice. Then X3 is a shorthand for the event {(1,1),(1,2),(2,1)}.
  2. Let Y be the random variable counting the number of heads during three subsequent coin tosses. Then Y0 is shorthand for the event {(tails),(tails),(tails)}

Discrete Random Variables

A random variable with a countable image, where X=a is an event.

Expectation Value

Let X be a discrete random variable over probability space (Ω,F,Pr)

The expectation value (or mean) of X is given by

E[X]=aX(Ω)αPr[X=α]

Example

Let Y denote the number of heads in three subsequent coin tosses.

  • Y=0 is {(t,t,t)}
  • Y=1 is {(h,t,t),(t,h,t),(t,t,h)}
  • Y=2 is {(h,h,t),(h,t,h),(t,h,h)}
  • Y=3 is {(h,h,h)}

Probabilities of event:

  • Pr[Y=0]=Pr[Y=3]=18
  • Pr[Y=1]=Pr[Y=2]=38

Expected value E[Y]=0(18)+1(38)+2(38)+3(18)=32

Linearity of Expectation

For random variables X,Y and real numbers a,b

E[aX+bY]=aE[X]+bE[Y]

Example: Hat Check Girl

Suppose n persons give their hat to the hat check girl. The girl is upset and hands each person a random hat (where the hat is chosen uniformly at random). How many persons can expect to get their own hat back?

Sample space is Ω={1,2,,n}

Allow subsets of Ω to be events such that σ-algebra F=𝒫(Ω).

For pΩ, the event {p} has the interpretation that p received his or her own hat. Therefore, by uniform distribution, the probability that any p receives his or her own hat is Pr[{p}]=1n

Use random variable Xi=1 if the ith person received his or her own hat back, and Xi=0 otherwise.

Pr[Xi=1]=1nE[Xi]=1Pr[Xi=1]+0Pr[Xi=0]=1n.

The random variable X=i=1nXi counts the number of persons receiving their own hat. By linearity,

E[X]=E[X1+X2++Xn]=i=1nE[Xi]=i=1n1n=n(1n)=1

So 1 person gets his or her own hat back, and the other n1 are in a riot outside the manager's office.

Bernoulli Distribution

Tossing a biased coin can be described by a random variable X that takes the value 1 if the outcome is heads and 0 if the outcome is tails. Assume that Pr[X=1]=p and Pr[X=0]=1p

Geometric Distribution

Suppose we keep tossing a biased coin that has Bernoulli distbibution with parameter p until heads event occurs. Let X be the number of coin flips needed in this experiment. We say that X is geometrically distributed with parameter p and th edensity is given as:

pX(x)=Pr[X=x]=p(1p)x1

for x.

E[X]=1pVar[X]=1pp2

Example: Coupon Collection

The hat check girl is a compulsive coupon collector. Currently, she is collecting charming Hanny Potter characters that are contained in overpriced cereal boxes. There are n different characters and each box contains one character. How many boxes of cereal does she have to buy for a complete collection?

Let X denote the number of boxes required to collect at least one character of each type.

Goal is to find E[X]. Let Xk be the random variables counting the number of boxes that the hat-check girl buys to get the (k+1)th character after she has already collected k characters.

The probability to draw one of the remaining characters is pk=(nk)/n. Hence X is geometrically distributed with parameter pk. Therefore

E[Xk]=1pk=n(nk)

Linearity shows that

E[X]=k=0n1E[Xk]=k=0n1nnk=nk=0n11k=nHn=nlogn