Random variable and expected valueΒΆ

Aufgabe

Consider a random variable \(X\) with the possible values \(0, 1, 2\) and \(3\). The table shows the probability distribution of \(X\) with \(p_1,p_2\in[0;1]\).

\(k\)

\(\vert\)

\(0\)

\(1\)

\(2\)

\(3\)

\(P(X=k)\vphantom{1\over2}\)

\(\vert\)

\(p_1\vphantom{1\over2}\)

\(\frac{3}{10}\vphantom{1\over2}\)

\(\frac{1}{5}\vphantom{1\over2}\)

\(p_2\vphantom{1\over2}\)

Demonstrate that the expectation value of \(X\) cannot exceed 2.2.

Solution

The expectation value of a random variable \(X\) is given by the sum over the products of all possible values and their corresponding probabilities:

\[E(X) = \sum\limits_k k\cdot p_k.\]

For the given probabilities, the expectation value becomes

\[E(X) = 0\cdot p_1+1\cdot \frac{3}{10}+2\cdot \frac{1}{5}+3\cdot p_2 = \frac{7}{10} + 3\cdot p_2.\]

\(p_1\) and \(p_2\) cannot be chosen arbitrarily because all probabilities need to sum up to one:

\[\begin{split}\begin{aligned} p_1+\frac{3}{10}+ \frac{1}{5}+p_2=1\\ \Rightarrow\quad p_2=\frac{1}{2}-p_1 \end{aligned}\end{split}\]

Furthermore, the probabilities \(p_1\) and \(p_2\) may not be negative, so that \(p_2\) takes on its maximum value for \(p_1=0\). Therefore, the probability \(p_2\) can take values from the interval \([0;\frac{1}{2}]\).

Taking the derivative of the expectation value with respect to the probability \(p_2\)

\[E'(p_2)=3\]

one finds that the expectation value increases with increasing probability \(p_2\). The maximum of the expectation value is therefore reached for the maximum value of \(p_2\) and is found to agree with the expected value

\[E\left(\frac{1}{2}\right)=\frac{7}{10}+\frac{3}{2}=\frac{11}{5}=2.2.\]

For the implementation in Sage, we will use \(k\) as an index for the corresponding probability. \(p_1\) and \(p_2\) defined in the problem will now be referred to as \(p_0\) and \(p_3\). In the Sage interface, it is possible to set the values for \(p_1\), \(p_2\), and \(p_3\) from which \(p_0\) is determined. At first, we will keep the values set to \(p_1=\frac{3}{10}\) and \(p_2=\frac{1}{5}\), as specified in the problem. By changing the value of \(p_3\) in the allowed interval, we can determine the maximum of the expectation value. By varying the other probabilities, we can also explore how the maximum of the expectation value depends on the probabilities fixed in the problem. We use a parameter eps to cope with rounding errors which occur when adding probabilities. The necessity of this parameter becomes clear by setting it to 0.