0% found this document useful (0 votes)
57 views82 pages

Eec 161 ch04

- The document discusses continuous random variables and their probability distributions. - The cumulative distribution function (CDF) gives the probability that a continuous random variable is less than or equal to a value. - The probability density function (PDF) describes the relative likelihood that a continuous random variable will take on certain values. It is the derivative of the CDF. - For a continuous random variable, the probability of obtaining any single value is 0, but the PDF and CDF allow calculating probabilities of events as areas under the PDF curve.

Uploaded by

Hanna Shui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views82 pages

Eec 161 ch04

- The document discusses continuous random variables and their probability distributions. - The cumulative distribution function (CDF) gives the probability that a continuous random variable is less than or equal to a value. - The probability density function (PDF) describes the relative likelihood that a continuous random variable will take on certain values. It is the derivative of the CDF. - For a continuous random variable, the probability of obtaining any single value is 0, but the PDF and CDF allow calculating probabilities of events as areas under the PDF curve.

Uploaded by

Hanna Shui
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 82

Chapter 4

Continuous Random
Variables
Example

What is the probability the temperature in Davis is exactly 90.3001 F?


Randomly pick a real number between 0 and 1, what is the probability that the number is
exactly 0.337890?

Unique feature of continuous random variable: the probability that X is equal


to any particular value is 0. So there is no PMF.
Section 4.2

The Cumulative Distribution


Function
Cumulative Distribution
Definition 4.1 Function (CDF)

The cumulative distribution function (CDF) of random variable X is

FX (x) = P [X ≤ x] .
Example

Let X be the temperature of Davis


x < -20,


 0
FX (x) = (x+20)/130 -20 ≤ x ≤110,

1

 x > 110.
Theorem 4.1

For any random variable X,

(a) FX(−∞) = 0 (c) P[x1 < X ≤ x2] = FX(x2) −


(b) FX(∞) = 1 FX(x1)
Quiz 4.2

The cumulative distribution function of the random variable Y is



0 y < 0,


FY (y ) =

y/4 0 ≤ y ≤ 4, (1)


1 y > 4.
Sketch the CDF of Y and calculate the following probabilities:

(a) P[Y ≤ −1]

(b) P[Y ≤ 1]

(c) P[2 < Y ≤ 3]

(d) P[Y > 1.5]


Quiz 4.2 Solution
The CDF of Y is
1
FY(y)


0.5 0 y < 0,


F Y (y ) = y/4 0 ≤ y ≤ 4, (1)
0 


1 y > 4.
0 2 4
y
From the CDF FY (y), we can calculate the probabilities:
(a) P[Y ≤ −1] = FY (−1) = 0
(b) P[Y ≤ 1] = FY (1) = 1/4
(c) P [2 < Y ≤ 3] = FY (3) − FY (2)
= 3/4 − 2/4 = 1/4.
(d) P [Y > 1.5] = 1 − P [Y ≤ 1.5]
= 1 − FY (1.5)
= 1 − (1.5)/4 = 5/8.
Section 4.3

Probability Density Function


Figure 4.2
FX (x)

p2

p1
∆ ∆ x
x1 x2

The graph of an arbitrary CDF FX(x).


Probability Density Function
Definition 4.3 (PDF)

The probability density function (PDF) of a continuous random variable


X is
dFX (x)
f X ( x) = .
dx
Example 4.3 Problem

Figure 4.3 depicts the PDF of a random variable X that describes the
voltage at the receiver in a modem. What are probable values of X?
Figure 4.3

fX (x)

x
−5 5

The PDF of the modem receiver voltage X.


Example 4.3 Solution

Note that there are two places where the PDF has high values and that
it is low elsewhere. The PDF indicates that the random variable is likely
to be near −5 V (corresponding to the symbol 0 transmitted) and near
+5 V (corresponding to a 1 transmitted). Values far from ±5 V (due to
strong distortion) are possible but much less likely.
Theorem 4.2

For a continuous random variable X with PDF fX(x),

(a) fX(x) ≥ 0 for all x,

Z x
(b) FX(x) = fX(u) du,
−∞

Z ∞
(c) fX(x) dx = 1.
−∞
Proof: Theorem 4.2

The first statement is true because FX(x) is a nondecreasing function


of x and therefore its derivative, fX(x), is nonnegative. The second fact
follows directly from the definition of fX(x) and the fact that FX(−∞) = 0.
The third statement follows from the second one and Theorem 4.1(b).
Theorem 4.3

Z x
2
P [x1 < X ≤ x2] = fX (x) dx.
x1
Proof: Theorem 4.3

From Theorem 4.1(c) and Theorem 4.2(b),

P [x1 < X ≤ x2] = FX (x2) − FX (x1)


Zx2 Z x1 Z x
2
= fX (x) dx − fX (x) dx = fX (x) dx. (1)
−∞ −∞ x1
Figure 4.4

fX (x)
FX (x2 ) − FX (x1 )

x
x1 x2

The PDF and CDF of X.


Example 4.5 Problem

Consider a continuous random variable Y with CDF

1

FY (y) 0

 y < 0,
0.5
FY (y ) = y 3 0 ≤ y ≤ 1, (1)



1 y > 1.
0
0 0.5 1 y
Find the PDF of Y and the probability that Y is between 1/4 and 3/4.
Example 4.5 Solution
We apply Definition 4.3 to the CDF FY (y). When FY (y) is piecewise differentiable, we
take the derivative of each piece:
3
fY (y) 2
3y 2

dFY (y) 0 < y ≤ 1,
fY (y) = = (1)
1 dy 0 otherwise.

0
0 0.5 1 y
Note that the PDF has values between 0 and 3. Its integral between any pair of
numbers is less than or equal to 1. The graph of fY (y) shows that there is a higher
probability of finding Y at the right side of the range of possible values than at the left side.
Either Theorem 4.1 or Theorem 4.3 can be used to calculate the probability of observing Y
between 1/4 and 3/4:

P [1/4 < Y ≤ 3/4] = FY (3/4) − FY (1/4) = (3/4)3 − (1/4)3 = 13/32, (2)


and equivalently,
Z 3/4 Z 3/4
P [1/4 < Y ≤ 3/4] = fY (y) dy = 3y 2 dy = 13/32. (3)
1/4 1/4
Quiz 4.3

Random variable X has probability density function



cxe−x/2 x ≥ 0,
f X ( x) = (1)
0 otherwise.
Sketch the PDF and find the following:
(a) the constant c
(b) the CDF FX(x)
(c) P[0 ≤ X ≤ 4]
(d) P[−2 ≤ X ≤ 2]
Quiz 4.3 Solution
(a) First we will find the constant c and then we will sketch the PDF. To find c, we
use the fact that
Z ∞ Z ∞
1= fX (x) dx = cxe−x/2 dx. (1)
−∞ 0
We evaluate this integral using integration by parts:
∞ Z ∞
1 = −2cxe−x/2 + 2ce−x/2 dx

0 0
| {z }
=0

−x/2
= −4ce = 4c. (2)
0
Thus c = 1/4 and X has the Erlang (n = 2, λ = 1/2) PDF
0.2
fX(x)

0.1 
(x/4)e−x/2 x ≥ 0,
fX (x) =
0 otherwise.
0
0 5 10 15
x
(b) To find the CDF FX(x), we first note X is a nonnegative random variable so that
FX(x) = 0 for all x < 0. For x ≥ 0, [Continued]
Quiz 4.3 Solution (Continued 2)
Z x Z x
y −y/2
FX (x) = e dy
fX (y) dy =
0 0 4
Z x
y −y/2 x 1 −y/2
=− e + e dy
2 0 0 2
x −x/2
=1− e − e−x/2 . (3)
2
The complete expression for the CDF is
1
FX(x)

0.5 x
+ 1 e−x/2
 
1− 2
x ≥ 0,
FX (x) =
0 ow.
0
0 5 10 15
x
(c) From the CDF FX(x),
P [0 ≤ X ≤ 4] = FX (4) − FX (0)
= 1 − 3e−2 . (4)
(d) Similarly,
P [−2 ≤ X ≤ 2] = FX (2) − FX (−2)
= 1 − 3e−1 . (5)
Section 4.4

Expected Values
Definition 4.4 Expected Value

The expected value of a continuous random variable X is


Z ∞
E [X ] = xfX (x) dx.
−∞
Example 4.6 Problem

Suppose RV X has PDF



1 0 ≤ x < 1,
fX (x) = (1)
 0 otherwise.
Find E[X]
Example 4.6 Solution

Z ∞ Z 1
E [X ] = xfX (x) dx = x dx = 1/2 (1)
−∞ 0
Example 4.7

In Example 4.5, find the expected value of Y

Z ∞ Z 1
E [Y ] = yfY (y ) dy = y(3y 2) dy = 3/4 (1)
−∞ 0
Theorem 4.4

The expected value of a function, g(X), of random variable X is


Z ∞
E [g(X)] = g(x)fX (x) dx.
−∞
Theorem 4.5

For any random variable X,

(a) E[X − µX ] = 0,

(b) E[aX + b] = a E[X] + b,

(c) Var[X] = E[X 2] − µ2


X,

(d) Var[aX + b] = a2 Var[X].


Example 4.9 Problem

Find the variance and standard deviation of the random variable X in


Example 4.6.
Example 4.9 Solution

To compute Var[X], we use Theorem 4.5(c): Var[X] = E[X 2] − µ2


X . We
calculate E[X 2] directly from Theorem 4.4 with g(X) = X 2:
h i Z ∞ Z 1
E X2 = x2fX (x) dx = x2 dx = 1/3 . (1)
−∞ 0
In Example 4.6, we have E[X] = 1/2. Thus q Var[X] = 1/3 − (1/2)2 =

1/12, and the standard deviation is σX = Var[X] = 1/ 12 = 0.289
Example 4.10 Problem

Find the variance and standard deviation of Y in Example 4.5.


Example 4.10 Solution

We proceed as in Example 4.9. We have fY (y) from Example 4.5 and


E[Y ] = 3/4 from Example 4.7:
Z ∞ Z 1  
2 2
h i
2
E Y = 2
y fY (y ) dy = y 3y dy = 3/5 . (1)
−∞ 0
Thus the variance is

Var [Y ] = 3/5 − (3/4)2 = 3/80 , (2)


and the standard deviation is σY = 0.194 .
Quiz 4.4

The probability density function of the random variable Y is



3y 2/2 −1 ≤ y ≤ 1,
fY (y ) = (1)
0 otherwise.
Sketch the PDF and find the following:

(a) the expected value E[Y ]

(b) the second moment E[Y 2]

(c) the variance Var[Y ]

(d) the standard deviation σY


Quiz 4.4 Solution
The PDF of Y is
3
2
fY(y)

 2
3y /2 −1 ≤ y ≤ 1,
1 fY (y) = (1)
0 otherwise.
0
−2 0 2
y
(a) The expected value of Y is
Z ∞ Z 1
3 1
(3/8)y 4 −1

E [Y ] = yfY (y) dy = (3/2)y dy = = 0. (2)
−∞ −1

Note that the above calculation wasn’t really necessary because E[Y ] = 0 whenever
the PDF fY (y) is an even function, i.e., fY (y) = fY (−y).
(b) The second moment of Y is
Z ∞ Z 1
5 1
 2 2 4

E Y = y fY (y) dy = (3/2)y dy = (3/10)y −1 = 3/5. (3)
−∞ −1

(c) The variance of Y is


Var[Y ] = E Y 2 − (E [Y ])2 = 3/5.
 
(4)
p p
(d) The standard deviation of Y is σY = Var[Y ] = 3/5.
Section 4.5

Families of Continuous Random


Variables
Definition 4.5 Uniform Random Variable

X is a uniform (a, b) random variable if the PDF of X is



1/(b − a) a ≤ x < b,
f X ( x) =
0 otherwise,
where the two parameters are b > a.
Theorem 4.6

If X is a uniform (a, b) random variable,



0

 x ≤ a,
• The CDF of X is FX (x) = (x − a)/(b − a) a < x ≤ b,



1 x > b.
• The expected value of X is E [X ] = (b + a)/2.
• The variance of X is Var [X ] = (b − a)2/12.
Example 4.11 Problem

The phase angle, Θ, of the signal at the input to a modem is uniformly


distributed between 0 and 2π radians. What are the PDF, CDF, expected
value, and variance of Θ?
Example 4.11 Solution

From the problem statement, we identify the parameters of the uniform


(a, b) random variable as a = 0 and b = 2π. Therefore the PDF and CDF
of Θ are


0
 θ ≤ 0,
1/(2π) 0 ≤ θ < 2π,

fΘ (θ ) =
0
FΘ (θ) = θ/(2π) 0 < x ≤ 2π, (1)
otherwise, 


1 x > 2π.
The expected value is E[Θ] = b/2 = π radians, and the variance is
Var[Θ] = (2π)2/12 = π 2/3 rad2.
Definition 4.6 Exponential Random Variable

X is an exponential (λ) random variable if the PDF of X is



λe−λx x ≥ 0,
f X ( x) =
0 otherwise,
where the parameter λ > 0.
Example 4.12 Problem

The probability that a telephone call lasts no more than t minutes is often
modeled as an exponential CDF.
1
FT(t) 
0.5 1 − e−t/3 t ≥ 0,
F T ( t) =
0 otherwise.
0
−5 0 5 t
What is the PDF of the duration in minutes of a telephone conversation?
What is the probability that a conversation will last between 2 and 4
minutes?
Example 4.12 Solution

We find the PDF of T by taking the derivative of the CDF:


0.4
fT(t) 
0.2 dFT (t) (1/3)e−t/3 t≥0
fT (t) = =
dt 0 otherwise
0
−5 0 5 t
From Definition 4.6, we recognize that T is an exponential (λ = 1/3)
random variable. The probability that a call lasts between 2 and 4 minutes
is

P [2 ≤ T ≤ 4] = F4 (4) − F2 (2) = e−2/3 − e−4/3 = 0.250. (1)


Example 4.13 Problem

In Example 4.12, what is E[T ], the expected duration of a telephone


call? What are the variance and standard deviation of T ? What is the
probability that a call duration is within ±1 standard deviation of the
expected call duration?
Example 4.13 Solution

Using the PDF fT(t) in Example 4.12, we calculate the expected duration
of a call:
Z ∞ Z ∞
1
E [T ] = tfT (t) dt = t e−t/3 dt. (1)
−∞ 0 3
Integration by parts (Appendix B, Math Fact B.10) yields
∞ Z ∞
E [T ] = −te−t/3 + e−t/3 dt = 3 minutes. (2)

0 0
To calculate the variance, we begin with the second moment of T :
Z ∞ Z ∞
1
t2 e−t/3 dt.
h i
E T2 = t2fT (t) dt = (3)
−∞ 0 3
[Continued]
Example 4.13 Solution (Continued 2)

Again integrating by parts, we have


∞ Z ∞ Z ∞
E T 2 = −t2e−t/3 + (2t)e−t/3 dt = 2 te−t/3 dt.
h i
(1)

0 0 0
R ∞ −t/3
With the knowledge that E[T ] = 3, we observe that 0 te dt =
3 E[T ] = 9. Thus E[T 2] = 6 E[T ] = 18 and
h i
Var [T ] = E T − (E [T ])2 = 18 − 32 = 9 minutes2.
2 (2)
q
The standard deviation is σT = Var[T ] = 3 minutes. The probability
that the call duration is within 1 standard deviation of the expected value
is

P [0 ≤ T ≤ 6] = FT (6) − FT (0) = 1 − e−2 = 0.865 (3)


Theorem 4.8

If X is an exponential (λ) random variable,



1 − e−λx x ≥ 0,
• The CDF of X is FX (x) =
0 otherwise.
• The expected value of X is E [X ] = 1/λ.
• The variance of X is Var [X ] = 1/λ2.
Definition 4.7 Erlang Random Variable

X is an Erlang (n, λ) random variable if the PDF of X is



n n−1 e−λx
λ x

x ≥ 0,

f X ( x) = (n − 1)!

0

otherwise,
where the parameter λ > 0, and the parameter n ≥ 1 is an integer.
Theorem 4.10

If X is an Erlang (n, λ) random variable, then


n n
(a) E[X] = , (b) Var[X] = 2 .
λ λ
Theorem 4.11

Let Kα denote a Poisson (α) random variable. For any x > 0, the CDF
of an Erlang (n, λ) random variable X satisfies
Pn−1 (λx)k e−λx


1 − k=0 . x ≥ 0,
FX (x) = 1 − FKλx (n − 1) = k!
0 otherwise.
Quiz 4.5

Continuous random variable X has E[X] = 3 and Var[X] = 9. Find the


PDF, fX(x), if

(a) X is an exponential random variable,

(b) X is a continuous uniform random variable.

(c) X is an Erlang random variable.


Quiz 4.5 Solution
(a) When X is an exponential (λ) random variable, E[X] = 1/λ and Var[X] = 1/λ2 .
Since E[X] = 3 and Var[X] = 9, we must have λ = 1/3. The PDF of X is

(1/3)e−x/3 x ≥ 0,

fX (x) = (1)
0 otherwise.
(b) We know X is a uniform (a, b) random variable. To find a and b, we apply Theo-
rem 4.6 to write
a+b
E [X] = =3 (2)
2
(b − a)2
Var[X] = = 9. (3)
12
This implies

a + b = 6, b − a = ±6 3. (4)
The only valid solution with a < b is
√ √
a = 3 − 3 3, b = 3 + 3 3. (5)
[Continued]
Quiz 4.5 Solution (Continued 2)
The complete expression for the PDF of X is
 √ √ √
1/(6 3) 3 − 3 3 < x < 3 + 3 3,
fX (x) = (6)
0 otherwise.
(c) We know that the Erlang (n, λ) random variable has PDF
( n n−1 −λx
λ x e
(n−1)!
x ≥ 0,
fX (x) = (7)
0 otherwise.

The expected value and variance are E[X] = n/λ and Var[X] = n/λ2 . This implies
n n
= 3, = 9. (8)
λ λ2
It follows that
n = 3λ = 9λ2 . (9)
Thus λ = 1/3 and n = 1. As a result, the Erlang (n, λ) random variable must be
the exponential (λ = 1/3) random variable with PDF

(1/3)e−x/3 x ≥ 0,

fX (x) = (10)
0 otherwise.
Section 4.6

Gaussian Random Variables


Definition 4.8 Gaussian Random Variable

X is a Gaussian (µ, σ) random variable if the PDF of X is


1 −(x−µ)2
/2σ 2 ,
f X ( x) = √ e
2πσ 2
where the parameter µ can be any real number and the parameter σ > 0.
Figure 4.5

0.8 0.8

0.6 0.6
fX(x) fX(x)
0.4 0.4

0.2 0.2

0 0
−2 0 2 4 6 −2 0 2 4 6
x x
(a) µ = 2, σ = 1/2 (b) µ = 2, σ = 2

Two examples of a Gaussian random variable X with expected value µ


and standard deviation σ.
Theorem 4.12

If X is a Gaussian (µ, σ) random variable,

E [X ] = µ Var [X ] = σ 2.
Theorem 4.13

If X is Gaussian (µ, σ), Y = aX + b is Gaussian (aµ + b, aσ).


Standard Normal Random
Definition 4.9 Variable

The standard normal random variable Z is the Gaussian (0, 1) random


variable.
Definition 4.10 Standard Normal CDF

The CDF of the standard normal random variable Z is


Z z
1 2
Φ(z) = √ e−u /2 du.
2π −∞
Theorem 4.14

If X is a Gaussian (µ, σ) random variable, the CDF of X is


x−µ
 
FX (x) = Φ .
σ
The probability that X is in the interval (a, b] is
b−µ a−µ
   
P [ a < X ≤ b] = Φ −Φ .
σ σ
Example 4.15 Problem

Suppose your score on a test is x = 46, a sample value of the Gaussian


(61, 10) random variable. Express your test score as a sample value of
the standard normal random variable, Z.
Example 4.15 Solution

Equation (4.50) indicates that z = (46 − 61)/10 = −1.5. Therefore your


score is 1.5 standard deviations less than the expected value.
Theorem 4.15

Φ(−z) = 1 − Φ(z).
Figure 4.6

0.5 0.5

0.4 0.4

0.3 0.3
fX(x)

fX(x)
0.2 ←Φ(z) 0.2 Φ(−z) → ← 1−Φ(z)
0.1 0.1

0 0
−4 −2 0 z 2 4 −4 −2 −z 0 z 2 4
x x
(a) (b)
Symmetry properties of the Gaussian (0, 1) PDF.
Example 4.16 Problem

If X is the Gaussian (61, 10) random variable, what is P[X ≤ 46]?


Example 4.16 Solution

Applying Theorem 4.14, Theorem 4.15, and the result of Example 4.15,
we have

P [X ≤ 46] = FX (46) = Φ(−1.5) = 1 − Φ(1.5) = 1 − 0.933 = 0.067. (1)


This suggests that if your test score is 1.5 standard deviations below
the expected value, you are in the lowest 6.7% of the population of test
takers.
Example 4.17 Problem

If X is a Gaussian (µ = 61, σ = 10) random variable, what is P[51 < X ≤ 71]?


Example 4.17 Solution

Applying Equation (4.50), Z = (X − 61)/10 and


X − 61
 
{51 < X ≤ 71} = −1 ≤ ≤ 1 = {−1 < Z ≤ 1} . (1)
10
The probability of this event is

P [−1 < Z ≤ 1] = Φ(1) − Φ(−1)


= Φ(1) − [1 − Φ(1)] = 2Φ(1) − 1 = 0.683. (2)
Standard Normal
Definition 4.11 Complementary CDF

The standard normal complementary CDF is


1
Z ∞ 2 /2
Q(z) = P [Z > z ] = √ e−u du = 1 − Φ(z).
2π z
Example 4.18 Problem

In q
an optical fiber transmission system, the probability of a bit error is
Q( γ/2), where γ is the signal-to-noise ratio. What is the minimum value
of γ that produces a bit error rate not exceeding 10−6?
Example 4.18 Solution

Referring −6 when z ≥ 4.75. There-


q to Table 4.2, we find that Q(z) < 10
fore, if γ/2 ≥ 4.75, or γ ≥ 45, the probability of error is less than 10−6.
Although 10( − 6) seems a very small number, most practical optical fiber
transmission systems have considerably lower binary error rates.
Quiz 4.6

X is the Gaussian (0, 1) random variable and Y is the Gaussian (0, 2)


random variable. Sketch the PDFs fX(x) and fY (y) on the same axes
and find:

(a) P[−1 < X ≤ 1],

(b) P[−1 < Y ≤ 1],

(c) P[X > 3.5],

(d) P[Y > 3.5].


Quiz 4.6 Solution
The PDFs of X and Y are:
0.4

fY(y)
← fX(x)
0.2
fX(x)
← fY(y)
0
−5 0 5
x y

The fact that Y has twice the standard deviation of X is reflected in the
greater spread of fY (y). However, it is important to remember that as
the standard deviation increases, the peak value of the Gaussian PDF
goes down.
Each of the requested probabilities can be calculated using Φ(z) function
and Table 4.2 or Q(z) and Table 4.3. [Continued]
Quiz 4.6 Solution (Continued 2)
(a) Since X is Gaussian (0, 1),

P [−1 < X ≤ 1] = FX (1) − FX (−1)


= Φ(1) − Φ(−1)
= 2Φ(1) − 1
= 0.6826. (1)
(b) Since Y is Gaussian (0, 2),

P [−1 < Y ≤ 1] = FY (1) − FY (−1)


! !
1 −1
=Φ −Φ
σY σY
1
 
= 2Φ − 1 = 0.383. (2)
2
(c) Again, since X is Gaussian (0, 1), P[X > 3.5] = Q(3.5) = 2.33 × 10−4.
(d) Since Y is Gaussian (0, 2),
3.5
 
P [Y > 3.5] = Q = 1 − Φ(1.75) = 0.04. (3)
2
Section 4.8

Matlab
4.8 Comment: The Gaussian CDF in Matlab

For the Gaussian CDF, we use the built-in Matlab error function
2 xZ
2
erf(x) = √ e−u du. (1)
π 0
It is related to the Gaussian CDF by
!
1 1 x
Φ(x) = + erf √ , (2)
2 2 2
which is how we implement the Matlab function phi(x).
Matlab rand
• y=rand(m,n) is Matlab’s approximation to a uniform (0, 1) random variable.

• It is an approximation for two reasons.

• First, rand produces pseudorandom numbers; the numbers seem random but are
actually the output of a deterministic algorithm.

• Second, rand produces a double precision floating point number, represented in


the computer by 64 bits.

• Thus Matlab distinguishes no more than 264 unique double precision floating point
numbers.

• By comparision, there are uncountably infinite real numbers in [0, 1).

• Even though rand is not random and does not have a continuous range, we can
for all practical purposes use it as a source of independent sample values of the
uniform (0, 1) random variable.
Quiz 4.8

Write a Matlab function t=t2rv(m) that generates m samples of a random


variable with the PDF fT |T >2(t) as given in Example 7.10.
Quiz 4.8 Solution
A natural way to produce random variables with PDF fT |T >2(t) is to generate samples of
T with PDF fT(t) and then to discard those samples which fail to satisfy the condition
T > 2. Here is a Matlab function that uses this method:

function t=t2rv(m)
i=0;lambda=1/3;
t=zeros(m,1);
while (i<m),
x=exponentialrv(lambda,1);
if (x>2)
t(i+1)=x;
i=i+1;
end
end

A second method exploits the fact that if T is an exponential (λ) random variable, then
T 0 = T + 2 has PDF fT 0(t) = fT |T >2(t). In this case the command

t=2.0+exponentialrv(1/3,m)

generates the vector t.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy