We flip a fair coin ten times. Find the probability of the following
events.
The number of heads and the number of tails are equal.
There are more heads than tails.
The -th flip and the -th flip are the same for
We flip at least four consecutive heads.
2.
The following approach is often called reservoir sampling. Suppose we have a sequence of items passing one by one. We want to maintain a sample of one item with
the property that it is uniformly distributed over all the items that we have seen so far. Assume that we do not know the total number of items in advance. How can we sample without storing all the items that we see.
Consider the following algorithms which just stores one item in memory at all times. When the first item appears, it is stored in memory. When the th item appears it replaces the item in memory with probability
. Explain why this algorithm solves the problem.
3.
Consider the following algorithm for computing the -smallest of a set of elements (-median):
Input: a set of different numbers and a number between and
Output: the smallest element of
Algorithm:
Choose from uniformly at random
If
then
If
then
If
then
Show that the expected running time of the algorithm is . (Hint: Try to write the running time as a recurrence and solve it).
4.
Given a circle with circumference and a marked point on the circle.
Choose additional points on the circle uniformly and independently at random. The random points partition the circle into n intervals.
What is the average interval length?
What is the expected interval length of the interval containing .
5.
Consider the interval on the real line. Choose a point of the interval uniformly at random. This point partitions the line into 2 intervals.
What is the expected length of the longer (shorter) interval?
What is the expected length of the interval containing the median (i.e., the point 0.5)