# What is the sample space of such random variable?

I see a question in Chinese senior high schools books:

Throwing a fair coin until either there is one Head or four Tails. Find the expectation of times of throwing. (You start throwing a coin, if you see Head, then the game suddenly over; and if you see four Tail, the game is over too. Only these two situation can the game be over.)

(The answer is $1\times\frac{1}{2}+2\times\frac{1}{4}+\cdots=\frac{15}{8}$)

I know that, if we want to calculate the expectation, we, of course, need to find the random variable first. In order to find the random variable, we need to know the sample space of the experiment. However, how can we say about this sample space? The throwing times are varing, not a constant like 3. If the times we throw is 3, the sample space is $\{(a_1,a_2,a_3)\mid \forall 1\le i\le 3,~a_i\in\{H,T\}\}$. But the sample space like this question, is not like this one. What is its sample space?

• Are you sure you copied the problem statement correctly? I don't see the sample space needing to be infinite, as the answer implies; the maximum number of throws required seems to be $4$; either you get 4 tails in a row; if not, you got one head somewhere within the first $4$ throws, which also means you won. – Ovi Jun 28 '17 at 13:56
• Ah well when you write $1\times\frac{1}{2}+2\times\frac{1}{4}+\cdots$, the $\cdots$ means it goes on infinitely; when you are adding a finite number of terms it is customary to write the last term after the $\cdots$. Writing down the sample space as $\{H, TH, TTH, TTTH, TTTT \}$ should be fine. Is there a reason why this is not acceptable? – Ovi Jun 28 '17 at 14:11
• Yes. The random variable $X$ maps from $\{H, TH, TTH, TTTH, TTTT \}$ to $\{1, 2, 3, 4 \}$, where each element of the sample space is mapped to the number of throws it represents. You have to find the expected value of $X$ using $E(X) = \sum_{x=1}^{4} x \cdot f(x)$ – Ovi Jun 28 '17 at 14:14
• Your random variable takes values in the set of binary (infinite) sequences $\{T, H\}^{\mathbb{N}}$. You want to compute the size (probability) of the set of sequences that start with either one of the sequences $\{H, TH, TTH, TTTH, TTTT\}$. – OR. Jun 28 '17 at 14:17
• Representing it as $\{(H),(T,H),(T,T,H),(T,T,T,H),(T,T,T,T)\}$ or $\{H, TH, TTH, TTTH, TTTT \}$ shouldn't matter. – Ovi Jun 28 '17 at 14:17

You could take $\Omega=\{T,H\}^4$ as sample space where all outcomes are equiprobable, and prescribe random variable $X$ as the function $\Omega\to\mathbb R$ determined by:

• $X(\omega)=1$ if $\omega_1=H$
• $X(\omega)=2$ if $\omega_1=T$ and $\omega_2=H$
• $X(\omega)=3$ if $\omega_1=\omega_2=T$ and $\omega_3=H$
• $X(\omega)=4$ otherwise

This gives the probabilities:

• $P(X=1)=\frac12$
• $P(X=2)=\frac14$
• $P(X=3)=\frac18$
• $P(X=4)=\frac18$

And expectation: $$\mathbb EX=\sum_{k=1}^4kP(X=k)=1\cdot\frac12+2\cdot\frac14+3\cdot\frac18+4\cdot\frac18=\frac{15}8$$

The probability space is $\langle\Omega,\wp(\Omega),P)$ where $\Omega=\{T,H\}^4$ and probability measure $P$ is defined by: $$P(S)=\frac{|S|}{16}$$

Fortunately in situations like this it is not necessary at all to construct a suitable sample space. We can restrict to finding the values of $P(X=k)$ by logical thinking. In many cases even that is not needed when it comes to calculating expectations.

It is a good thing however to know about the construction of sample spaces, and for that it is good practice to construct one now and then.

• The definition of expectation is $E(X)=\sum_{i=1}^kx_iP(X=x_i)$. Since $X$ is a function on $\Omega$, every element should have the function value defined on it. How do we define the value of, say $(H,T,H,T)$? Is $4$? – Eric Jun 28 '17 at 14:32
• $X(H,T,H,T)=1$ since here $\omega_1=H$. The outcomes have the form $(\omega_1,\omega_2,\omega_3,\omega_4)$ where $\omega_i\in\{H,T\}$ for $i=1,2,3,4$. In my answer $X(\omega)$ is indeed defined for every $\omega\in\Omega$. – drhab Jun 28 '17 at 14:34
• So the $P(X,T,H,T)$ is $1\cdot 2\cdot 2\cdot 2$ over $2^4$ right? – Eric Jun 28 '17 at 14:37
• $P(X,T,H,T)$ is a confusing notation here. There are $16$ equiprobable outcomes and $1\times2\times2\times2$ of them have $\omega_1=H$, so $P(X=1)=\frac{8}{16}=\frac12$. – drhab Jun 28 '17 at 14:40
• You're welcome. I am too much an autodidact for that. I learned this at university by means of scripts and cannot assist you when it comes to references. If you have teacher, then trust him/her too and ask him/her :-). – drhab Jun 28 '17 at 14:59

You can use as a sample space the set $$\Omega=\left\{H,TH,TTH,TTTH,TTTT\right\}$$ The probabilities of these outcomes are $\frac{1}{2}$, $\frac{1}{4}$, $\frac{1}{8}$, $\frac{1}{16}$, and $\frac{1}{16}$ respectively.

[You asked how to show this rigorously. Each throw is independent from every other throw, and on each throw the probability of $H$ or $T$ is $\frac{1}{2}$. The probability of independent events is the product of the probabilities of each of those events.]

Let $X$ be the number of throws in each outcome. That's just the length of the word: \begin{align*} X(H) &= 1 \\ X(TH) &= 2 \\ X(TTH) &= 3 \\ X(TTTH) &= 4 \\ X(TTTT) &= 4 \end{align*} So the expected value is: $$E(X) = 1 \left(\frac{1}{2}\right) +2 \left(\frac{1}{4}\right) +3 \left(\frac{1}{8}\right) +4 \left(\frac{1}{16}\right) +4 \left(\frac{1}{16}\right) = \frac{15}{8}$$