# 7.3: Problems on Distribution and Density Functions

• • Contributed by Paul Pfeiffer
• Professor emeritus (Computational and Applied Mathematics) at Rice University

Exercise $$\PageIndex{1}$$

(See Exercises 3 and 4 from "Problems on Random Variables and Probabilities"). 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, with probabilities 0.08, 0.13, 0.06, 0.09, 0.14, 0.11, 0.12, 0.07, 0.11, 0.09. Determine and plot the distribution function $$F_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);
ddbn
Enter row matrix of VALUES  X
Enter row matrix of PROBABILITIES  PX    % See MATLAB plot

Exercise $$\PageIndex{2}$$

(See Exercise 6 from "Problems on Random Variables and Probabilities"). 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.0 I_{C_6} + 3.5 I_{C_7} + 7.5 I_{C_8}$$

Determine and plot the distribution function for $$X$$.

T = [3.5 5 3.5 7.5 5 5 3.5 7.5];
pc = 0.01*[10 15 15 20 10 5 10 15];
[X,PX] = csort(T,pc);
ddbn
Enter row matrix of VALUES  X
Enter row matrix of PROBABILITIES  PX    % See MATLAB plot

Exercise $$\PageIndex{3}$$

(See Exercise 12 from "Problems on Random Variables and Probabilities"). 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 and plot the distribution function for the random variable $$X = I_A + I_B + I_C + I_D$$, which counts the number of the events which occur on a trial.

npr06_12
Minterm probabilities in pm, coefficients in c
T = sum(mintable(4)); % Alternate solution.  See Exercise 6.2.12 from "Problems on Random Variables and Probabilities"
[X,PX] = csort(T,pm);
ddbn
Enter row matrix of VALUES  X
Enter row matrix of PROBABILITIES  PX    % See MATLAB plot


Exercise $$\PageIndex{4}$$

Suppose a is a ten digit number. A wheel turns up the digits 0 through 9 with equal probability on each spin. On ten spins what is the probability of matching, in order, k or more of the ten digits in $$a$$, $$0 \le k \le 10$$? Assume the initial digit may be zero.

$$P =$$ cbinom(10, 0.1, 0 : 10).

Exercise $$\PageIndex{5}$$

In a thunderstorm in a national park there are 127 lightning strikes. Experience shows that the probability of of a lightning strike starting a fire is about 0.0083. What is the probability that $$k$$ fires are started, $$k =$$ 0,1,2,3?

P = ibinom(127,0.0083,0:3) P = 0.3470 0.3688 0.1945 0.0678

Exercise $$\PageIndex{6}$$

A manufacturing plant has 350 special lamps on its production lines. On any day, each lamp could fail with probability $$p =$$ 0.0017. These lamps are critical, and must be replaced as quickly as possible. It takes about one hour to replace a lamp, once it has failed. What is the probability that on any day the loss of production time due to lamp failaures is $$k$$ or fewer hours, $$k = 0, 1, 2, 3, 4, 5$$?

P = 1 - chinom(350, 0.0017, 1:6)

=  0.5513    0.8799    0.9775    0.9968    0.9996    1.0000

Exercise $$\PageIndex{7}$$

Two hundred persons buy tickets for a drawing. Each ticket has probability 0.008 of winning. What is the probability of $$k$$ or fewer winners, $$k = 2, 3, 4$$?

P = 1 - cbinom(200,0.008,3:5) = 0.7838 0.9220 0.9768

Exercise $$\PageIndex{8}$$

Two coins are flipped twenty times. What is the probability the results match (both heads or both tails) $$k$$ times, $$0 \le k \le 20$$?

P = ibinom(20,1/2,0:20)

Exercise $$\PageIndex{9}$$

Thirty members of a class each flip a coin ten times. What is the probability that at least five of them get seven or more heads?

p = cbinom(10,0.5,7) = 0.1719

P = cbinom(30,p,5) = 0.6052

Exercise $$\PageIndex{10}$$

For the system in Exercise 6, call a day in which one or more failures occur among the 350 lamps a “service day.” Since a Bernoulli sequence “starts over” at any time, the sequence of service/nonservice days may be considered a Bernoulli sequence with probability p1, the probability of one or more lamp failures in a day.

1. Beginning on a Monday morning, what is the probability the first service day is the first, second, third, fourth, fifth day of the week?
2. What is the probability of no service days in a seven day week?

p1 = 1 - (1 - 0.0017)^350 = 0.4487 k = 1:5; (prob given day is a service day)

1. P = p1*(1 - p1).^(k-1) = 0.4487  0.2474  0.1364  0.0752  0.0414

2. P0 = (1 - p1)^7 = 0.0155

Exercise $$\PageIndex{11}$$

For the system in Exercise 6 and Exercise 10 assume the plant works seven days a week. What is the probability the third service day occurs by the end of 10 days? Solve using the negative binomial distribution; repeat using the binomial distribution.

p1 = 1 - (1 - 0.0017)^350 = 0.4487

• P = sum(nbinom(3,p1,3:10)) = 0.8990
• Pa = cbinom(10,p1,3) = 0.8990

Exercise $$\PageIndex{12}$$

A residential College plans to raise money by selling “chances” on a board. Fifty chances are sold. A player pays $10 to play; he or she wins$30 with probability $$p =$$ 0.2. The profit to the College is

$$X = 50 \cdot 10 - 30 N$$, where $$N$$ is the number of winners

Determine the distribution for $$X$$ and calculate $$P(X > 0)$$, $$P(X \ge 200)$$, and $$P(X \ge 300)$$

N = 0:50;
PN = ibinom(50,0.2,0:50);
X = 500 - 30*N;
Ppos = (X>0)*PN'
Ppos =  0.9856
P200 = (X>=200)*PN'
P200 =  0.5836
P300 = (X>=300)*PN'
P300 =  0.1034


Exercise $$\PageIndex{13}$$

A single six-sided die is rolled repeatedly until either a one or a six turns up. What is the probability that the first appearance of either of these numbers is achieved by the fifth trial or sooner?

P = 1 - (2/3)^5 = 0.8683

Exercise $$\PageIndex{14}$$

Consider a Bernoulli sequence with probability $$p =$$ 0.53 of success on any component trial.

1. The probability the fourth success will occur no later than the tenth trial is determined by the negative binomial distribution. Use the procedure nbinom to calculate this probability .
2. Calculate this probability using the binomial distribution.
1. P = sum(nbinom(4,0.53,4:10)) = 0.8729
2. Pa = cbinom(10,0.53,4) = 0.8729

Exercise $$\PageIndex{15}$$

Fifty percent of the components coming off an assembly line fail to meet specifications for a special job. It is desired to select three units which meet the stringent specifications. Items are selected and tested in succession. Under the usual assumptions for Bernoulli trials, what is the probability the third satisfactory unit will be found on six or fewer trials?

P = cbinom(6,0.5,3) = 0.6562

Exercise $$\PageIndex{16}$$

The number of cars passing a certain traffic count position in an hour has Poisson (53) distribution. What is the probability the number of cars passing in an hour lies between 45 and 55 (inclusive)? What is the probability of more than 55?

P1 = cpoisson(53,45) - cpoisson(53,56) = 0.5224

P2 = cpoisson(53,56) = 0.3581

Exercise $$\PageIndex{17}$$

Compare $$P(X \le k)$$ and $$P(Y \le k)$$ for $$X~$$ binomial(5000, 0.001) and $$Y~$$ Poisson (5), for $$0 \le k \le 10$$. Do this directly with ibinom and ipoisson. Then use the m-procedure bincomp to obtain graphical results (including a comparison with the normal distribution).

k = 0:10;
Pb = 1 - cbinom(5000,0.001,k+1);
Pp = 1 - cpoisson(5,k+1);
disp([k;Pb;Pp]')
0    0.0067    0.0067
1.0000    0.0404    0.0404
2.0000    0.1245    0.1247
3.0000    0.2649    0.2650
4.0000    0.4404    0.4405
5.0000    0.6160    0.6160
6.0000    0.7623    0.7622
7.0000    0.8667    0.8666
8.0000    0.9320    0.9319
9.0000    0.9682    0.9682
10.0000    0.9864    0.9863

bincomp
Enter the parameter n  5000
Enter the parameter p  0.001
Binomial-- stairs
Poisson--  -.-.
gtext('Exercise 17')

Exercise $$\PageIndex{18}$$

Suppose $$X~$$ binomial (12, 0.375), $$Y~$$ Poisson (4.5), and $$Z~$$ exponential (1/4.5). For each random variable, calculate and tabulate the probability of a value at least $$k$$, for integer values $$3 \le k \le 8$$.

k = 3:8;
Px = cbinom(12,0.375,k);
Py = cpoisson(4.5,k);
Pz = exp(-k/4.5);
disp([k;Px;Py;Pz]')
3.0000    0.8865    0.8264    0.5134
4.0000    0.7176    0.6577    0.4111
5.0000    0.4897    0.4679    0.3292
6.0000    0.2709    0.2971    0.2636
7.0000    0.1178    0.1689    0.2111
8.0000    0.0390    0.0866    0.1690

Exercise $$\PageIndex{19}$$

The number of noise pulses arriving on a power circuit in an hour is a random quantity having Poisson (7) distribution. What is the probability of having at least 10 pulses in an hour? What is the probability of having at most 15 pulses in an hour?

P1 = cpoisson(7,10) = 0.1695 P2 = 1 - cpoisson(7,16) = 0.9976

Exercise $$\PageIndex{20}$$

The number of customers arriving in a small specialty store in an hour is a random quantity having Poisson (5) distribution. What is the probability the number arriving in an hour will be between three and seven, inclusive? What is the probability of no more than ten?

P1 = cpoisson(5,3) - cpoisson(5,8) = 0.7420

P2 = 1 - cpoisson(5,11) = 0.9863

Exercise $$\PageIndex{21}$$

Random variable $$X~$$ binomial (1000, 0.1).

1. Determine $$P(X \ge 80)$$, $$P(X \ge 100)$$, $$P(X \ge 120)$$
2. Use the appropriate Poisson distribution to approximate these values.
k = [80 100 120];
P = cbinom(1000,0.1,k)
P  =  0.9867    0.5154    0.0220
P1 = cpoisson(100,k)
P1 =  0.9825    0.5133    0.0282

Exercise $$\PageIndex{22}$$

The time to failure, in hours of operating time, of a televesion set subject to random voltage surges has the exponential (0.002) distribution. Suppose the unit has operated successfully for 500 hours. What is the (conditional) probability it will operate for another 500 hours?

$$P(X > 500 + 500|X > 500) = P(X > 500) = e^{-0.002 \cdot 500} = 0.3679$$

Exercise $$\PageIndex{23}$$

For $$X~$$ exponential ($$\lambda$$), determine $$P(X \ge 1/\lambda)$$, $$P(X \ge 2/\lambda)$$.

$$P(X > k\lambda) = e^{-\lambda k/ \lambda} = e^{-k}$$

Exercise $$\PageIndex{24}$$

Twenty “identical” units are put into operation. They fail independently. The times to failure (in hours) form an iid class, exponential (0.0002). This means the “expected” life is 5000 hours. Determine the probabilities that at least $$k$$, for $$k$$ = 5,8,10,12,15, will survive for 5000 hours.

p = exp(-0.0002*5000)
p = 0.3679
k = [5 8 10 12 15];
P = cbinom(20,p,k)
P = 0.9110  0.4655  0.1601  0.0294  0.0006

Exercise $$\PageIndex{25}$$

Let $$T~$$ gamma (20, 0.0002) be the total operating time for the units described in Exercise 24.

1. Use the m-function for the gamma distribution to determine $$P(T \le 100,000)$$.
2. Use the Poisson distribution to determine $$P(T \le 100,000)$$.

P1 = gammadbn(20,0.0002,100000) = 0.5297 P2 = cpoisson(0.0002*100000,20) = 0.5297

Exercise $$\PageIndex{26}$$

The sum of the times to failure for five independent units is a random variable $$X~$$ gamma (5, 0.15). Without using tables or m-programs, determine $$P(X le 25)$$.

$$P(X \le 25) = P(Y \ge 5)$$, $$Y~$$ Poisson $$(0.15 \cdot 25 = 3.75)$$

$$P(Y \ge 5) = 1 - P(Y \le 4) = 1 - e^{-3.35} (1 + 3.75 + \dfrac{3.75^2}{2} + \dfrac{3.75^3}{3!} + \dfrac{3.75^4}{24}) = 0.3225$$

Exercise $$\PageIndex{27}$$

Interarrival times (in minutes) for fax messages on a terminal are independent, exponential ($$\lambda =$$ 0.1). This means the time $$X$$ for the arrival of the fourth message is gamma(4, 0.1). Without using tables or m-programs, utilize the relation of the gamma to the Poisson distribution to determine $$P \le 30$$.

$$P(X \le 30) = P(Y \ge 4)$$, $$Y~$$ poisson ($$0.2 \cdot 30 = 3$$)

$$P(Y \ge 4) = 1 - P(Y \le 3) = 1 - e^{-3} (1 + 3 + \dfrac{3^2}{2} + \dfrac{3^3}{3!}) = 0.3528$$

Exercise $$\PageIndex{28}$$

Customers arrive at a service center with independent interarrival times in hours, which have exponential (3) distribution. The time $$X$$ for the third arrival is thus gamma (3, 3). Without using tables or m-programs, determine $$P(X \le 2)$$.

$$P(X \le 2) = P(Y \ge 3)$$, $$Y ~$$ poisson ($$3 \cdot 2 = 6$$)

$$P(Y \ge 3) = 1 - P(Y \le 2) = 1 - e^{-6} (1 + 6 + 36/2) = 0.9380$$

Exercise $$\PageIndex{29}$$

Five people wait to use a telephone, currently in use by a sixth person. Suppose time for the six calls (in minutes) are iid, exponential (1/3). What is the distribution for the total time $$Z$$ from the present for the six calls? Use an appropriate Poisson distribution to determine $$P(Z \le 20)$$.

$$Z~$$ gamma (6, 1/3).

$$P(Z \le 20) = P(Y \ge 6)$$, $$Y~$$ poisson$$(1/3 \cdot 20)$$

$$P(Y \ge 6)$$ = cpoisson(20/3, 6) = 0.6547

Exercise $$\PageIndex{30}$$

A random number generator produces a sequence of numbers between 0 and 1. Each of these can be considered an observed value of a random variable uniformly distributed on the interval [0, 1]. They assume their values independently. A sequence of 35 numbers is generated. What is the probability 25 or more are less than or equal to 0.71? (Assume continuity. Do not make a discrete adjustment.)

p = cbinom(35,0.71,25) = 0.5620

Exercise $$\PageIndex{31}$$

Five “identical” electronic devices are installed at one time. The units fail independently, and the time to failure, in days, of each is a random variable exponential (1/30). A maintenance check is made each fifteen days. What is the probability that at least four are still operating at the maintenance check?

p = exp(-15/30) = 0.6065 P = cbinom(5,p,4) = 0.3483

Exercise $$\PageIndex{32}$$

Suppose $$X ~ N$$(4, 81). That is, $$X$$ has gaussian distribution with mean $$\mu$$ = 4 and variance $$\sigma^2$$ = 81.

1. Use a table of standardized normal distribution to determine $$P(2 < X < 8)$$ and $$P(|X - 4| \le 5)$$.
2. Calculate the probabilities in part (a) with the m-function gaussian.

a.

$$P(2 < X < 8) = \phi((8 - 4)/9) - \phi ((2 - 4)/9)$$ =

$$\phi (4/9) + \phi (2/9) - 1 = 0.6712 + 0.5875 - 1 = 0.2587$$

$$P(|X - 4| \le 5) = 2\phi(5/9) - 1 = 1.4212 - 1 = 0.4212$$

b.

P1 = gaussian(4,81,8) - gaussian(4,81,2)
P1 = 0.2596
P2 = gaussian(4,81,9) - gaussian(4,84,-1)
P2 = 0.4181

Exercise $$\PageIndex{33}$$

Suppose $$X ~ N(5, 81)$$. That is, $$X$$ has gaussian distribution with $$\mu$$ = 5 and $$\sigma^2$$ = 81. Use a table of standardized normal distribution to determine $$P(3 < X < 9)$$ and $$P(|X - 5| le 5)$$. Check your results using the m-function gaussian.

$$P(3 < X < 9) = \phi ((9 - 5)/9) - \phi ((3 - 5)/9) = \phi(4/9) + \phi(2/9) - 1 = 0.6712 + 0.5875 - 1 = 0.2587$$

$$P(|X - 5| \le 5) = 2 \phi(5/9) - 1 = 1.4212 - 1 = 0.4212$$

P1 = gaussian(5,81,9) - gaussian(5,81,3)
P1 = 0.2596
P2 = gaussian(5,81,10) - gaussian(5,84,0)
P2 = 0.4181

Exercise $$\PageIndex{34}$$

Suppose $$X ~ N(3, 64)$$. That is, $$X$$ has gaussian distribution with $$\mu$$ = 3 and $$\sigma^2$$ = 64. Use a table of standardized normal distribution to determine $$P(1 < X < 9)$$ and $$P(|X - 3| le 4)$$. Check your results with the m-function gaussian.

$$P(1 < X < 9) = \phi((9 - 3)/8) - \phi(1 - 3)/9) =$$

$$\phi(0.75) + \phi(0.25) - 1 = 0.7734 + 0.5987 - 1 = 0.3721$$

$$P(|X - 3| \le 4) = 2 \phi(4/8) - 1 = 1.3829 - 1 = 0.3829$$

P1 = gaussian(3,64,9) - gaussian(3,64,1)
P1 = 0.3721
P2 = gaussian(3,64,7) - gaussian(3,64,-1)
P2 = 0.3829

Exercise $$\PageIndex{35}$$

Items coming off an assembly line have a critical dimension which is represented by a random variable $$~ N$$ (10, 0.01). Ten items are selected at random. What is the probability that three or more are within 0.05 of the mean value $$\mu$$.

p = gaussian(10,0.01,10.05) - gaussian(10,0.01,9.95)
p =  0.3829
P = cbinom(10,p,3)
P =  0.8036

Exercise $$\PageIndex{36}$$

The result of extensive quality control sampling shows that a certain model of digital watches coming off a production line have accuracy, in seconds per month, that is normally distributed with $$\mu$$ = 5 and $$\sigma^2$$ = 300. To achieve a top grade, a watch must have an accuracy within the range of -5 to +10 seconds per month. What is the probability a watch taken from the production line to be tested will achieve top grade? Calculate, using a standardized normal table. Check with the m-function gaussian.

$$P(-5 \le X \le 10) = \phi(5/ \sqrt{300}) + \phi(10/\sqrt{300}) - 1 = \phi(0.289) + \phi(0.577) - 1 = 0.614 + 0.717 - 1 = 0.331$$

$$P =$$ gaussian(5, 300, 10) - gaussian(5, 300, -5) = 0.3317

Exercise $$\PageIndex{37}$$

Use the m-procedure bincomp with various values of $$n$$ from 10 to 500 and $$p$$ from 0.01 to 0.7, to observe the approximation of the binomial distribution by the Poisson.

Experiment with the m-procedure bincomp.

Exercise $$\PageIndex{38}$$

Use the m-procedure poissapp to compare the Poisson and gaussian distributions. Use various values of $$\mu$$ from 10 to 500.

Experiment with the m-procedure poissapp.

Exercise $$\PageIndex{39}$$

Random variable $$X$$ has density $$f_X(t) = \dfrac{3}{2} t^2$$, $$-1 \le t \le 1$$ (and zero elsewhere).

1. Determine $$P(-0.5 \le X < 0.8)$$, $$P(|X| > 0.5)$$, $$P(|X - 0.25) \le 0.5)$$.
2. Determine an expression for the distribution function.
3. Use the m-procedures tappr and cdbn to plot an approximation to the distribution function.
1. $$\dfrac{3}{2} \int t^2 = t^3/2$$

$$P1 = 0.5 * (0.8^3 - (-0.5)^3) = 0.3185$$ $$P2 = 2 \int_{0.5}^{1} \dfrac{3}{2} t^2 = (1 - (-0.5)^3) = 7/8$$

$$P3 = P(|X - 0.25| \le 0.5) = P(-0.25 \le X \le 0.75) = \dfrac{1}{2}[(3/4)^3 - (-1/4)^3] = 7/32$$

2. $$F_X (t) = \int_{-1}^{1} f_X = \dfrac{1}{2} (t^3 + 1)$$
3. tappr
Enter matrix [a b] of x-range endpoints  [-1 1]
Enter number of x approximation points  200
Enter density as a function of t  1.5*t.^2
Use row matrices X and PX as in the simple case
cdbn
Enter row matrix of VALUES  X
Enter row matrix of PROBABILITIES  PX    % See MATLAB plot

Exercise $$\PageIndex{40}$$

Random variable $$X$$ has density function $$f_X(t) = t - \dfrac{3}{8}t^3$$, $$0 \le t \le 2$$ (and zero elsewhere).

1. Determine $$P(X \le 0.5)$$, $$P(0.5 \le X < 1.5)$$, $$P(|X - 1| < 1/4)$$.
2. Determine an expression for the distribution function.
3. Use the m-procedures tappr and cdbn to plot an approximation to the distribution function.
1. $$\int (t - \dfrac{3}{8} t^2) = \dfrac{t^2}{2} - \dfrac{t^3}{8}$$

$$P1 = 0.5^2/2 - 0.5^3/8 = 7/64$$ $$P2 = 1.5^2 /2 - 1.5^3 /8 - 7/64 = 19/32$$ $$P3 = 79/256)$$

2. $$F_X (t) = \dfrac{t^2}{2} - \dfrac{t^3}{8}$$, $$0 \le t \le 2$$
3. tappr
Enter matrix [a b] of x-range endpoints  [0 2]
Enter number of x approximation points  200
Enter density as a function of t  t - (3/8)*t.^2
Use row matrices X and PX as in the simple case
cdbn
Enter row matrix of VALUES  X
Enter row matrix of PROBABILITIES  PX    % See MATLAB plot

Exercise $$\PageIndex{41}$$

Random variable $$X$$ has density function

$$f_X (t) = \begin{cases} (6/5) t^2 & \text{for } 0 \le t \le 1 \\ (6/5) (2 -t) & \text{for } 1 < t \le 2 \end{cases} = I[0, 1] (t) \dfrac{6}{5} t^2 + I_{(1, 2]} (t) \dfrac{6}{5} (2 -t)$$

1. Determine $$P(X \le 0.5)$$, $$P(0.5 \le X < 1.5)$$, $$P(|X - 1| < 1/4)$$.
2. Determine an expression for the distribution function.
3. Use the m-procedures tappr and cdbn to plot an approximation to the distribution function.
1. $$P1 = \dfrac{6}{5} \int_{0}^{1/2} t^2 = 1/20$$ $$P2 = \dfrac{6}{5} \int_{1/2}^{1} t^2 + \dfrac{6}{5} \int_{1}^{3/2} (2 - t) = 4/5$$

$$P3) = \dfrac{6}{5} \int_{3/4}^{1} t^2 + \dfrac{6}{5} \int_{1}^{5/4} (2 - t) = 79/160$$

2. $$F_X (t) = \int_{0}^{1} f_X = I_{[0, 1]} (t) \dfrac{2}{5}t^3 + I_{(1, 2]} (t) [-\dfrac{7}{5} + \dfrac{6}{5} (2t - \dfrac{t^2}{2})]$$

3. tappr
Enter matrix [a b] of x-range endpoints  [0 2]
Enter number of x approximation points  400
Enter density as a function of t  (6/5)*(t<=1).*t.^2 + ...
(6/5)*(t>1).*(2 - t)
Use row matrices X and PX as in the simple case
cdbn
Enter row matrix of VALUES  X
Enter row matrix of PROBABILITIES  PX    % See MATLAB plot