Docsity

Computer programs exercises, Exercises of Electrical Engineering

Toggle sidebar
bg1
Homework Week 1
Yates and Goodman 3e Problem/Solution Set: 1.3.5, 1.3.12, and 1.4.3
Problem 1.3.5 •
Computer programs are classified by the length of the source code and by the
execution time. Programs with more than 150 lines in the source code are big
(B). Programs with ≤150 lines are little (L). Fast programs (F) run in less
than 0.1 seconds. Slow programs (W) require at least 0.1 seconds. Monitor a
program executed by a computer. Observe the length of the source code and
the run time. The probability model for this experiment contains the following
information: P[LF ]=0.5, P[BF ]=0.2, and P[B W ]=0.2. What is the sample
space of the experiment? Calculate the following probabilities: P[W], P[B], and
P[W∪B].
Problem 1.3.5 Solution
The sample space of the experiment is
S={LF, BF , LW,B W }.(1)
From the problem statement, we know that P[LF ] = 0.5, P[BF ] = 0.2 and
P[BW ] = 0.2. This implies P[LW ] = 1 −0.5−0.2−0.2 = 0.1. The questions
can be answered using Theorem 1.5.
(a) The probability that a program is slow is
P [W] = P [LW ] + P [BW ] = 0.1+0.2=0.3.(2)
(b) The probability that a program is big is
P [B] = P [BF ] + P [BW ] = 0.2+0.2=0.4.(3)
(c) The probability that a program is slow or big is
P [W∪B] = P [W] + P [B]−P [BW ]=0.3+0.4−0.2=0.5.(4)
1
pf3

Partial preview of the text

Download Computer programs exercises and more Exercises Electrical Engineering in PDF only on Docsity!

Homework Week 1

Yates and Goodman 3e Problem/Solution Set: 1.3.5, 1.3.12, and 1.4.

Problem 1.3.5 •

Computer programs are classified by the length of the source code and by the execution time. Programs with more than 150 lines in the source code are big (B). Programs with ≤ 150 lines are little (L). Fast programs (F ) run in less than 0.1 seconds. Slow programs (W ) require at least 0.1 seconds. Monitor a program executed by a computer. Observe the length of the source code and the run time. The probability model for this experiment contains the following information: P[LF ] = 0.5, P[BF ] = 0.2, and P[BW ] = 0.2. What is the sample space of the experiment? Calculate the following probabilities: P[W ], P[B], and P[W ∪ B].

Problem 1.3.5 Solution

The sample space of the experiment is

S = {LF, BF, LW, BW }. (1)

From the problem statement, we know that P[LF ] = 0 .5, P[BF ] = 0 .2 and P[BW ] = 0.2. This implies P[LW ] = 1 − 0. 5 − 0. 2 − 0 .2 = 0.1. The questions can be answered using Theorem 1.5.

(a) The probability that a program is slow is

P [W ] = P [LW ] + P [BW ] = 0.1 + 0.2 = 0. 3. (2)

(b) The probability that a program is big is

P [B] = P [BF ] + P [BW ] = 0.2 + 0.2 = 0. 4. (3)

(c) The probability that a program is slow or big is

P [W ∪ B] = P [W ] + P [B] − P [BW ] = 0.3 + 0. 4 − 0 .2 = 0. 5. (4)

Problem 1.3.12 

Using only the three axioms of probability, prove P[∅] = 0.

Problem 1.3.12 Solution

It is tempting to use the following proof:

Since S and φ are mutually exclusive, and since S = S ∪ φ,

1 = P [S ∪ φ] = P [S] + P [φ].

Since P[S] = 1, we must have P[φ] = 0.

The above “proof” used the property that for mutually exclusive sets A 1 and A 2 ,

P [A 1 ∪ A 2 ] = P [A 1 ] + P [A 2 ]. (1)

The problem is that this property is a consequence of the three axioms, and thus must be proven. For a proof that uses just the three axioms, let A 1 be an arbitrary set and for n = 2, 3 ,.. ., let An = φ. Since A 1 = ∪∞ i=1Ai, we can use Axiom 3 to write

P [A 1 ] = P [∪∞ i=1Ai] = P [A 1 ] + P [A 2 ] +

∑^ ∞

i=

P [Ai]. (2)

By subtracting P[A 1 ] from both sides, the fact that A 2 = φ permits us to write

P [φ] +

∑^ ∞

n=

P [Ai] = 0. (3)

By Axiom 1, P[Ai] ≥ 0 for all i. Thus,

n=3 P[Ai]^ ≥^ 0.^ This implies P[φ]^ ≤^ 0. Since Axiom 1 requires P[φ] ≥ 0, we must have P[φ] = 0.

Problem 1.4.3 •

You have a shuffled deck of three cards: 2, 3, and 4. You draw one card. Let Ci denote the event that card i is picked. Let E denote the event that the card chosen is a even-numbered card.