# 6.2: Problems on Random Variables and Probabilities


Exercise $$\PageIndex{1}$$

The following simple random variable is in canonical form:

$$X = -3.75 I_A - 1.13 I_B + 0 I_C + 2.6 I_D$$.

Express the events $$\{X \in (-4, 2]\}$$, $$\{X \in (0, 3]\}$$, $$\{X \in (-\infty, 1]\}$$, and {$$X \ge 0$$} in terms of $$A$$, $$B$$, $$C$$, and $$D$$.

• $$A \bigvee B \bigvee C$$
• $$D$$
• $$A \bigvee B \bigvee C$$
• $$C$$
• $$C \bigvee D$$

Exercise $$\PageIndex{2}$$

Random variable $$X$$, in canonical form, is given by $$X = -2I_{A} - I_B + I_C + 2I_D + 5I_E$$.

Express the events $$\{X \in [2, 3)\}$$, $$\{X \le 0\}$$, $$\{X < 0\}$$, $$\{|X - 2| \le 3\}$$, and $$\{X^2 \ge 4\}$$, in terms of $$A, B, C, D, and E$$.

• $$D$$
• $$A \bigvee B$$
• $$A \bigvee B$$
• $$B \bigvee C \bigvee D \bigvee E$$
• $$A \bigvee D \bigvee E$$

Exercise $$\PageIndex{3}$$

The class $$\{C_j: 1 \le j \le 10\}$$ is a partition. Random variable $$X$$ has values {1, 3, 2, 3, 4, 2, 1, 3, 5, 2} on $$C_1$$ through $$C_{10}$$, respectively. Express X\) in canonical form.

T = [1 3 2 3 4 2 1 3 5 2];
[X,I] = sort(T)
X =   1   1   2   2   2   3   3   3   4   5
I =   1   7   3   6  10   2   4   8   5   9

$$X = I_A + 2I_B + 3I_C + 4I_D + 5I_E$$

$$A = C_1 \bigvee C_7$$, $$B = C_3 \bigvee C_6 \bigvee C_{10}$$, $$C = C_2 \bigvee C_4 \bigvee C_8$$, $$D = C_5$$, $$E = C_9$$

Exercise $$\PageIndex{4}$$

The class $$\{C_j: 1 \le j \le 10\}$$ in Exercise has respective probabilities 0.08, 0.13, 0.06, 0.09, 0.14, 0.11, 0.12, 0.07, 0.11, 0.09. Determine the distribution for $$X$$

T = [1 3 2 3 4 2 1 3 5 2];
pc = 0.01*[8 13 6 9 14 11 12 7 11 9];
[X,PX] = csort(T,pc);
disp([X;PX]')
1.0000    0.2000
2.0000    0.2600
3.0000    0.2900
4.0000    0.1400
5.0000    0.1100

Exercise $$\PageIndex{5}$$

A wheel is spun yielding on an equally likely basis the integers 1 through 10. Let Ci be the event the wheel stops at $$i$$, $$1 \le i \le 10$$. Each $$P(C_i) = 0.1$$. If the numbers 1, 4, or 7 turn up, the player loses ten dollars; if the numbers 2, 5, or 8 turn up, the player gains nothing; if the numbers 3, 6, or 9 turn up, the player gains ten dollars; if the number 10 turns up, the player loses one dollar. The random variable expressing the results may be expressed in primitive form as

$$X = -10I_{C_1} + 0I_{C_2} + 10I_{C_3} - 10I_{C_4} + 0I_{C_5} + 10I_{C_6} - 10I_{C_7} + 0I_{C_8} + 10I_{C_9} - I_{C_{10}}$$

• Determine the distribution for $$X$$, (a) by hand, (b) using MATLAB.
• Determine $$P(X < 0)$$, $$P(X > 0)$$.
p = 0.1*ones(1,10);
c = [-10 0 10 -10 0 10 -10 0 10 -1];
[X,PX] = csort(c,p);
disp([X;PX]')
-10.0000    0.3000
-1.0000    0.1000
0    0.3000
10.0000    0.3000
Pneg = (X<0)*PX'
Pneg =  0.4000
Ppos = (X>0)*PX'
Ppos =  0.300

Exercise $$\PageIndex{6}$$

A store has eight items for sale. The prices are $3.50,$5.00, $3.50,$7.50, $5.00,$5.00, $3.50, and$7.50, respectively. A customer comes in. She purchases one of the items with probabilities 0.10, 0.15, 0.15, 0.20, 0.10 0.05, 0.10 0.15. The random variable expressing the amount of her purchase may be written

$$X = 3.5 I_{C_1} + 5.0 I_{C_2} + 3.5 I_{C_3} + 7.5 I_{C_4} + 5.0 I_{C_5} + 5.0I_{C_6} + 3.5 I_{C_7} + 7.5I_{C_8}$$

Determine the distribution for $$X$$ (a) by hand, (b) using MATLAB.

p = 0.01*[10 15 15 20 10  5 10 15];
c = [3.5 5 3.5 7.5 5 5 3.5 7.5];
[X,PX] = csort(c,p);
disp([X;PX]')
3.5000    0.3500
5.0000    0.3000
7.5000    0.3500

Exercise $$\PageIndex{7}$$

Suppose $$X$$, $$Y$$ in canonical form are

$$X = 2 I_{A_1} + 3 I_{A_2} + 5 I_{A_3}$$ $$Y = I_{B_1} + 2 I_{B_2} + 3I_{B_3}$$

The $$P(A_i)$$ are 0.3, 0.6, 0.1, respectively, and the $$P(B_j)$$ are 0.2 0.6 0.2. Each pair {$$A_i, B_j$$} is independent. Consider the random variable $$Z = X + Y$$. Then $$Z = 2 + 1$$ on $$A_1 B_1$$, $$Z = 3 + 3$$ on $$A_2 B_3$$, etc. Determine the value of $$Z$$ on each $$A_i B_j$$ and determine the corresponding $$P(A_i B_j)$$. From this, determine the distribution for $$Z$$.

A = [2 3 5];
B = [1 2 3];
a = rowcopy(A,3);
b = colcopy(B,3);
Z =a + b               % Possible values of sum Z = X + Y
Z = 3     4     6
4     5     7
5     6     8
PA = [0.3 0.6 0.1];
PB = [0.2 0.6 0.2];
pa= rowcopy(PA,3);
pb = colcopy(PB,3);
P = pa.*pb            % Probabilities for various values
P =  0.0600    0.1200    0.0200
0.1800    0.3600    0.0600
0.0600    0.1200    0.0200
[Z,PZ] = csort(Z,P);
disp([Z;PZ]')         % Distribution for Z = X + Y
3.0000    0.0600
4.0000    0.3000
5.0000    0.4200
6.0000    0.1400
7.0000    0.0600
8.0000    0.0200

Exercise $$\PageIndex{8}$$

For the random variables in Exercise, let $$W = XY$$. Determine the value of $$W$$ on each $$A_i B_j$$ and determine the distribution of $$W$$.

XY = a.*b
XY = 2     3     5               % XY values
4     6    10
6     9    15

W        PW               % Distribution for W = XY
2.0000    0.0600
3.0000    0.1200
4.0000    0.1800
5.0000    0.0200
6.0000    0.4200
9.0000    0.1200
10.0000    0.0600
15.0000    0.0200

Exercise $$\PageIndex{9}$$

A pair of dice is rolled.

1. Let $$X$$ be the minimum of the two numbers which turn up. Determine the distribution for $$X$$
2. Let $$Y$$ be the maximum of the two numbers. Determine the distribution for $$Y$$.
3. Let $$Z$$ be the sum of the two numbers. Determine the distribution for $$Z$$.
4. Let $$W$$ be the absolute value of the difference. Determine its distribution.
t = 1:6;
c = ones(6,6);
[x,y] = meshgrid(t,t)
x =  1     2     3     4     5     6     % x-values in each position
1     2     3     4     5     6
1     2     3     4     5     6
1     2     3     4     5     6
1     2     3     4     5     6
1     2     3     4     5     6
y =  1     1     1     1     1     1     % y-values in each position
2     2     2     2     2     2
3     3     3     3     3     3
4     4     4     4     4     4
5     5     5     5     5     5
6     6     6     6     6     6
m = min(x,y);                         % min in each position
M = max(x,y);                         % max in each position
s = x + y;                            % sum x+y in each position
d = abs(x - y);                       % |x - y| in each position
[X,fX] = csort(m,c)                   % sorts values and counts occurrences
X =   1     2     3     4     5     6
fX = 11     9     7     5     3     1    % PX = fX/36
[Y,fY] = csort(M,c)
Y =   1     2     3     4     5     6
fY =  1     3     5     7     9    11    % PY = fY/36
[Z,fZ] = csort(s,c)
Z =   2     3     4     5     6     7     8     9    10    11    12
fZ =  1     2     3     4     5     6     5     4     3     2     1  %PZ = fZ/36
[W,fW] = csort(d,c)
W =   0     1     2     3     4     5
fW =  6    10     8     6     4     2    % PW = fW/36

Exercise $$\PageIndex{10}$$

Minterm probabilities $$p(0)$$ through $$p(15)$$ for the class $$\{A, B , C, D\}$$ are, in order,

0.072 0.048 0.018 0.012 0.168 0.112 0.042 0.028 0.062 0.048 0.028 0.010 0.170 0.110 0.040 0.

Determine the distribution for random variable

$$X = -5.3I_A - 2.5 I_B + 2.3 I_C + 4.2 I_D - 3.7$$

% file npr06_10.m
% Data for Exercise 6.2.10.
pm = [ 0.072 0.048 0.018 0.012 0.168 0.112 0.042 0.028 ...
0.062 0.048 0.028 0.010 0.170 0.110 0.040 0.032];
c  = [-5.3 -2.5 2.3 4.2 -3.7];
disp('Minterm probabilities are in pm, coefficients in c')
npr06_10
Minterm probabilities are in pm, coefficients in c
canonic
Enter row vector of coefficients  c
Enter row vector of minterm probabilities  pm
Use row matrices X and PX for calculations
Call for XDBN to view the distribution
XDBN
XDBN =
-11.5000    0.1700
-9.2000    0.0400
-9.0000    0.0620
-7.3000    0.1100
-6.7000    0.0280
-6.2000    0.1680
-5.0000    0.0320
-4.8000    0.0480
-3.9000    0.0420
-3.7000    0.0720
-2.5000    0.0100
-2.0000    0.1120
-1.4000    0.0180
0.3000    0.0280
0.5000    0.0480
2.8000    0.0120

Exercise $$\PageIndex{11}$$

On a Tuesday evening, the Houston Rockets, the Orlando Magic, and the Chicago Bulls all have games (but not with one another). Let A be the event the Rockets win, $$B$$ be the event the Magic win, and $$C$$ be the event the Bulls win. Suppose the class {$$A, B, C$$} is independent, with respective probabilities 0.75, 0.70 0.8. Ellen's boyfriend is a rabid Rockets fan, who does not like the Magic. He wants to bet on the games. She decides to take him up on his bets as follows:

• $10 to 5 on the Rockets --- i.e. She loses five if the Rockets win and gains ten if they lose •$10 to 5 against the Magic
• even $5 to 5 on the Bulls. Ellen's winning may be expressed as the random variable $$X = -5 I_A + 10 I_{A^c} + 10 I_B - 5 I_{B^c} - 5 I_C + 5I_{C^c} = -15 I_A + 15 I_B - 10 I_C + 10$$ Determine the distribution for $$X$$. What are the probabilities Ellen loses money, breaks even, or comes out ahead? Answer P = 0.01*[75 70 80]; c = [-15 15 -10 10]; canonic Enter row vector of coefficients c Enter row vector of minterm probabilities minprob(P) Use row matrices X and PX for calculations Call for XDBN to view the distribution disp(XDBN) -15.0000 0.1800 -5.0000 0.0450 0 0.4800 10.0000 0.1200 15.0000 0.1400 25.0000 0.0350 PXneg = (X<0)*PX' PXneg = 0.2250 PX0 = (X==0)*PX' PX0 = 0.4800 PXpos = (X>0)*PX' PXpos = 0.2950 Exercise $$\PageIndex{12}$$ The class {$$A, B, C, D$$} has minterm probabilities $$pm = 0.001 *$$ [5 7 6 8 9 14 22 33 21 32 50 75 86 129 201 302] • Determine whether or not the class is independent. • The random variable $$X = I_A + I_B + I_C + I_D$$counts the number of the events which occur on a trial. Find the distribution for X and determine the probability that two or more occur on a trial. Find the probability that one or three of these occur on a trial. Answer npr06_12 Minterm probabilities in pm, coefficients in c a = imintest(pm) The class is NOT independent Minterms for which the product rule fails a = 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 canonic Enter row vector of coefficients c Enter row vector of minterm probabilities pm Use row matrices X and PX for calculations Call for XDBN to view the distribution XDBN = 0 0.0050 1.0000 0.0430 2.0000 0.2120 3.0000 0.4380 4.0000 0.3020 P2 = (X>=2)*PX' P2 = 0.9520 P13 = ((X==1)|(X==3))*PX' P13 = 0.4810 Exercise $$\PageIndex{13}$$ James is expecting three checks in the mail, for$20, $26, and$33 dollars. Their arrivals are the events $$A, B, C$$. Assume the class is independent, with respective probabilities 0.90, 0.75, 0.80. Then

$$X = 20 I_A + 26 I_B + 33 I_C$$

represents the total amount received. Determine the distribution for $$X$$. What is the probability he receives at least $50? Less than$30?

c = [20 26 33 0];
P = 0.01*[90 75 80];
canonic
Enter row vector of coefficients  c
Enter row vector of minterm probabilities  minprob(P)
Use row matrices X and PX for calculations
Call for XDBN to view the distribution
disp(XDBN)
0    0.0050
20.0000    0.0450
26.0000    0.0150
33.0000    0.0200
46.0000    0.1350
53.0000    0.1800
59.0000    0.0600
79.0000    0.5400
P50 = (X>=50)*PX'
P50 =  0.7800
P30 = (X <30)*PX'
P30 =  0.0650

Exercise $$\PageIndex{14}$$

A gambler places three bets. He puts down two dollars for each bet. He picks up three dollars (his original bet plus one dollar) if he wins the first bet, four dollars if he wins the second bet, and six dollars if he wins the third. His net winning can be represented by the random variable

$$X = 3I_A + 4I_B + 6I_C - 6$$, with $$P(A) = 0.5$$, $$P(B) = 0.4$$, $$P(C) = 0.3$$

Assume the results of the games are independent. Determine the distribution for $$X$$.

c = [3 4 6 -6];
P = 0.1*[5 4 3];
canonic
Enter row vector of coefficients  c
Enter row vector of minterm probabilities  minprob(P)
Use row matrices X and PX for calculations
Call for XDBN to view the distribution
dsp(XDBN)
-6.0000    0.2100
-3.0000    0.2100
-2.0000    0.1400
0    0.0900
1.0000    0.1400
3.0000    0.0900
4.0000    0.0600
7.0000    0.0600

Exercise $$\PageIndex{15}$$

Henry goes to a hardware store. He considers a power drill at $35, a socket wrench set at$56, a set of screwdrivers at $18, a vise at$24, and hammer at \$8. He decides independently on the purchases of the individual items, with respective probabilities 0.5, 0.6, 0.7, 0.4, 0.9. Let $$X$$ be the amount of his total purchases. Determine the distribution for $$X$$.

c = [35 56 18 24 8 0];
P = 0.1*[5 6 7 4 9];
canonic
Enter row vector of coefficients  c
Enter row vector of minterm probabilities  minprob(P)
Use row matrices X and PX for calculations
Call for XDBN to view the distribution
disp(XDBN)
0    0.0036
8.0000    0.0324
18.0000    0.0084
24.0000    0.0024
26.0000    0.0756
32.0000    0.0216
35.0000    0.0036
42.0000    0.0056
43.0000    0.0324
50.0000    0.0504
53.0000    0.0084
56.0000    0.0054
59.0000    0.0024
61.0000    0.0756
64.0000    0.0486
67.0000    0.0216
74.0000    0.0126
77.0000    0.0056
80.0000    0.0036
82.0000    0.1134
85.0000    0.0504
88.0000    0.0324
91.0000    0.0054
98.0000    0.0084
99.0000    0.0486
106.0000    0.0756
109.0000    0.0126
115.0000    0.0036
117.0000    0.1134
123.0000    0.0324
133.0000    0.0084
141.0000    0.0756

Exercise $$\PageIndex{16}$$

A sequence of trials (not necessarily independent) is performed. Let $$E_i$$ be the event of success on the $$i$$th component trial. We associate with each trial a "payoff function" $$X_i = aI_{E_i} + b I_{E_i^c}$$. Thus, an amount $$a$$ is earned if there is a success on the trial and an amount $$b$$ (usually negative) if there is a failure. Let $$S_n$$ be the number of successes in the $$n$$ trials and $$W$$ be the net payoff. Show that $$W = (a - b) S_n + bn$$.

$$X_i = aI_{E_i} + b(1 - I_{E_i}) = (a - b) I_{E_i} + b$$

$$W = \sum_{i = 1}^{n} X_i = (a - b) \sum_{i = 1}^{n} I_{E_i} + bn = (a - b) S_n + bn$$

Exercise $$\PageIndex{17}$$

A marker is placed at a reference position on a line (taken to be the origin); a coin is tossed repeatedly. If a head turns up, the marker is moved one unit to the right; if a tail turns up, the marker is moved one unit to the left.

1. Show that the position at the end of ten tosses is given by the random variable

$$X = \sum_{i = 1}^{10} I_{E_i} - \sum_{i = 1}^{10} I_{E_i^c} = 2 \sum_{i = 1}^{10} I_{E_i} - 10 = 2S_{10} - 10$$

where $$E_i$$ is the event of a head on the $$i$$th toss and $$S_{10}$$ is the number of heads in ten trials.

• After ten tosses, what are the possible positions and the probabilities of being in each?

$$X_i = I_{E_i} - I_{E_i^c} = I_{E_i} - (1 - I_{E_i}) = 2I_{E_i} - 1$$

$$X = \sum_{i = 1}^{10} X_i = 2\sum_{i = 1}^{n} I_{E_i} - 10$$

S = 0:10;
PS = ibinom(10,0.5,0:10);
X = 2*S - 10;
disp([X;PS]')
-10.0000    0.0010
-8.0000    0.0098
-6.0000    0.0439
-4.0000    0.1172
-2.0000    0.2051
0    0.2461
2.0000    0.2051
4.0000    0.1172
6.0000    0.0439
8.0000    0.0098
10.0000    0.0010

Exercise $$\PageIndex{18}$$

Margaret considers five purchases in the amounts 5, 17, 21, 8, 15 dollars with respective probabilities 0.37, 0.22, 0.38, 0.81, 0.63. Anne contemplates six purchases in the amounts 8, 15, 12, 18, 15, 12 dollars, with respective probabilities 0.77, 0.52, 0.23, 0.41, 0.83, 0.58. Assume that all eleven possible purchases form an independent class.

1. Determine the distribution for $$X$$, the amount purchased by Margaret.
2. Determine the distribution for $$Y$$, the amount purchased by Anne.
3. Determine the distribution for $$Z = X + Y$$, the total amount the two purchase.

Suggestion for part (c). Let MATLAB perform the calculations.

[r,s] = ndgrid(X,Y);
[t,u] = ndgrid(PX,PY);
z = r + s;
pz = t.*u;
[Z,PZ] = csort(z,pz);

% file npr06_18.m
cx = [5 17 21 8 15 0];
cy = [8 15 12 18 15 12 0];
pmx = minprob(0.01*[37 22 38 81 63]);
pmy = minprob(0.01*[77 52 23 41 83 58]);
npr06_18
[X,PX] = canonicf(cx,pmx);  [Y,PY] = canonicf(cy,pmy);
[r,s] = ndgrid(X,Y);   [t,u] = ndgrid(PX,PY);
z = r + s;   pz = t.*u;
[Z,PZ] = csort(z,pz);
a = length(Z)
a  =  125              % 125 different values
plot(Z,cumsum(PZ))  % See figure     Plotting details omitted

This page titled 6.2: Problems on Random Variables and Probabilities is shared under a CC BY 3.0 license and was authored, remixed, and/or curated by Paul Pfeiffer via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.