# CDF of a random variable defined by a coin toss.

Assume that you choose point $\xi$ from $[1,4]$ in the following way. You toss a coin that can give head, tail or stood on edge with equal probabilities. If it stood on edge, then $\xi = 3$. If tail, then you going to choose $\xi$ randomly from $[1,2]$. If head, then randomly from $[2,4]$. The question is what are cumulative density function, mean and variance of such random variable?

Let's start from CDF. It is obvious that for $t \leq 1$ $F_\xi(t) = 0$ and for $t \geq 4$ $F_\xi(t) = 1$. I assumed that $F_\xi(t) = \frac{1}{3}\cdot\frac{t-1}{1}$ for $1 \leq t < 2$ and $F_\xi(t) = \frac{1}{3}+\frac{t-2}{4-2}=\frac{3t-4}{6}$ for $2 \leq t < 4$. Am I right or are there any mistakes here? Further computations of $M\xi$ and $D\xi$ are rather straightforward from CDF (split integral from $1$ to $4$ into two integrals from $1$ to $2$ and from $2$ to $4$ with corresponding derivatives of CDF on each interval).

• You need to assume a nonzero probability for the coin to fall on edge, otherwise the random variable is undefined (experiment never stops). Maybe what you have in mind is setting P(edge)=$\epsilon$ and the taking the limit as $\epsilon\to0$...
– A.G.
Oct 13, 2017 at 22:52
• @A.G., the probability that the coin will fall on edge is $\frac{1}{3}$. Oct 13, 2017 at 23:11
• @A.G. I think you have mistook the problem for a more interesting one. It's pretty clear from OP's calculation of the cdf that they mean if the coin lands heads or tails the variable is chosen uniformly from the intervals, not recursively. Oct 13, 2017 at 23:44
• @Hasek your cdf is not right. You should have a jump at three. Furthermore, when I plug in $t=4$ to the cdf you wrote down I get $3/2.$ that can't be right. Oct 13, 2017 at 23:49
• @Hasek My bad, did not realize this is a 3-sided coin ;)
– A.G.
Oct 14, 2017 at 3:45

Not quite. You do not seem to have taken into account the fact that the coin could fall on it's edge, so the probability of $3$ appearing is larger than you have shown it.

More precisely, you are right that the CDF is zero before $1$ and one after $4$.

Let us find $P(\xi \leq k)$. Note that if we define the random variable $C = 0,1,2$ with probability $\frac 13$ each (for the coin toss with $0$ representing the coin falling on an edge, $1$ representing tail and $2$ representing head), then $$P(\xi \leq k) = P(C = 0)P(\xi \leq k | C = 0) + P(C = 1)P(\xi \leq k | C = 1) + P(C = 2)P(\xi \leq k | C = 2)$$

Now we can split into cases. Suppose that $1 \leq k < 2$. Then, note that the first and last term above would be zero, so the answer is just $\frac{1}{3}\frac{k-1}{1} = \frac {k-1}3$, as you had predicted.

Suppose that $2 \leq k < 3$. Note that the second event occurs with probability $\frac 13$ now, since if $C=1$, then every element picked uniformly from $[1,2]$ is smaller than $k$. The third event also occurs, and has probability $\frac{k - 2}{6}$. So the answer would be $\frac{1}{3} + \frac{k-2}{6} = \frac{k}{6}$.

For $3 \leq k \leq 4$, all three events above occur. Note that now, both the first and second event occur with probability $\frac 13$ each, and the third event occurs with probability $\frac{k-2}{6}$, again. Hence, here the answer is $\frac{k + 2}{6}$.

Hence, the final CDF is: $$F(k) = \begin{cases} 0 & k \leq 1 \\ \frac{k-1}{3} & 1 \leq k < 2 \\ \frac k6 & 2 \leq k < 3 \\ \frac{k+2}6 & 3 \leq k \leq 4 \\ 1 & k \geq 4 \end{cases}$$

NOTE : As expected, there is a jump at $3$ of the CDF : the probability that $\xi = 3$ is non-zero, so this expected. This was not observed in your function, for example.

Now, you can use this function to get down to your expectation and variance calculations.