random variables 1. introduction in the measurement process, the presence of random variables and...

38
Random Variables 1

Upload: cordelia-eaton

Post on 23-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

1

Random Variables

Page 2: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

2

Introduction

• In the measurement process, the presence of random variables and signals are inevitable.

• Therefore, the study of system identification requires good background on random signals.

• In these slides, several concepts related to random variables and signals will be reviewed.

Page 3: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

3

Random vs. Deterministic

• A characteristic of a deterministic signal or sequence is that it can be reproduced exactly in contrast to random signal.

• The randomness or unpredictability of the value of a certain variable in a modeling context arises generally from the limits of scientific knowledge or the desire to work with models of low complexity.

• Measurements, in particular, introduce an unpredictable part because of their finite accuracy.

Page 4: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

4

Example: a random signalAn example of an unpredictable signal is the acceleration measured on the wheel axis of a car during a particular time interval when it is is driving on different test tracks.

Page 5: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

5

Example: a random signal

• These signals are nondeterministic because there is no prescribed formula to generate such a time record synthetically.

• A consequence of this nondeterministic nature is that the recording of the acceleration will be different when it is measured for a different period in time with the same sensor mounted at the same location, while the car is driving at the same speed over the same road segment.

Page 6: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

6

Reproduction of random signals

• Artificial generation of random signals is of interest in simulation purposes.

• But since these signals are nondeterministic, reproducing them exactly is not possible.

• A valid alternative is to try to generate a time sequence that has “similar features” to the original random signal.

Page 7: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

7

Reproduction of random signals

• An example of such a feature is the sample mean of all the 2000 samples of each time record in the previous Figure.

• Let the acceleration sequence be denoted by x(k), with k = 0, 1, 2, . . . The sample mean is then defined as

• Other features are available to describe random variables and signals as will see next.

.)(2000

2000

1

k

x kx

Page 8: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

8

Cumulative distribution function (CDF)

The CDF function FX(α) of a random variable X gives the probability of the event { X ≤ α } , which is denoted by

.],Pr[)( forXFX

Page 9: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

9

The axioms of probability imply that the CDF has the following properties:

Cumulative distribution function (CDF)

Page 10: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

10

Probability density function (PDF)

• Another, more frequently used, characterization of a random variable is the PDF. The PDF fX (α) of a random variable X is equal to the derivative of the CDF function FX (α)

• The CDF can be obtained by integrating the PDF:• The PDF has the property fX(α) ≥ 0 and

• We can derive the probability of the event { a < X ≤ b } by using

d

dFf XX

)()(

.)()(

dfF XX

.1)(

df X

.)(]Pr[ b

a

X dfbXa

Page 11: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

11

Gaussian random variable (normal)

• A Gaussian random variable X has the following PDF:

.where

,2

1)(

2

2

2

)(

RandR

ef X

Page 12: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

12

The expected value of a random variable

• The CDF and PDF fully specify the behavior of a random variable in the sense that they determine the probabilities of events corresponding to that random variable. However, these functions cannot be determined experimentally in a trivial way

• Fortunately, in many problems, it is sufficient to specify the behavior of a random variable in terms of certain features such as the expected value and variance of this random variable.

Page 13: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

13

Expected value

• The expected value, also called mean, of a random variable X is given by

• The expected value is the average of all values, weighted by their probability; the value “expected” beforehand given the probability distribution.

• The expected value is often called the first-order moment. Higher-order moments of a random variable can also be obtained.

.)(][E

dfX X

Page 14: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

14

The nth-order Moment

• The nth-order moment of a random variable X is given by

• A useful quantity related to the second-order moment of a random variable is the variance.

.)(][E

dfX Xnn

Page 15: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

15

Variance• The variance of a random variable X is given by

• Sometimes the standard deviation is used:

• The expression for the variance can be simplified as follows:

• This shows that, for a zero-mean random variable (E[X] = 0), the variance equals its second-order moment E[X2].

].])[E[(E]var[ 2XXX

.]var[][std XX

.])[E(E

])[E(][E][E2E

]])[E(][E2[E]var[

22

22

22

XX

XXXX

XXXXX

Page 16: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

16

Gaussian random variable• The PDF of a Gaussian RV is

completely specified by the two constants µ and σ2. These constants can be obtained as

• This is usually expressed using the notation:

• MATLAB command: randn

.]var[

,]E[2

X

X

).,(~ 2X

Page 17: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

17

Uniform Distribution

• A uniformly distributed random variable assumes values in the range from 0 to 1 with equal probability.

• MATLAB command: rand

Page 18: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

18

Multiple random variables

• It often occurs in practice that several random variables are measured at the same time.

• This may be an indication that these random

variables are related.

• The probability of events that involve the joint behavior of multiple random variables is described by the joint CDF or joint PDF functions.

Page 19: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

19

Joint CDF & PDF

• The joint CDF of two random variables X and Y is defined as

• Similarly, we can define the joint PDF as

].andPr[),(, YXF YX

.),(),( ,,

YXYX Ff

Page 20: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

20

Correlation

• With the definition of the joint PDF of two random variables, the expectation of functions of two random variables can be defined as well.

• Two relevant expectations are the correlation and the covariance of two random variables.

• The correlation of two random variables X and Y is

.dd),(]E[ ,,

YXYX fXYR

Page 21: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

21

Covariance

• Let µX = E[X] and µY = E[Y] denote the means of the random variables X and Y, respectively.

• Then the covariance of variables X and Y is

• Intuition: the covariance describes how much the two variables “change together” (positive if they change in the same way, negative if they change in opposite ways).

YXYX

YXYX

R

YXC

,

, )]-)(E[(

Page 22: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

22

Uncorrelated Random Variables

• Two random variables X and Y are uncorrelated if their covariance = 0, i.e.

• Examples: The education level of a person is correlated

with their income. Hair color may be uncorrelated with income

(at least in an ideal world).

YXYX

YXYXYX

XYR

RC

][E

0

,

,,

Page 23: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

23

Vector of Random Variables

The case of two RVs can be extended to the vector case. Let X be a vector with entries Xi for i = 1, 2, . . . , n that jointly have a Gaussian distribution with mean and the covariance matrix of X is:

• Remarks:

),cov(),cov(),cov(

),cov(),cov(),cov(

),cov(),cov(),cov(

])-)(X-E[(X)cov(

,

][E

][E

][E

E[X]

21

22212

12111

TXX

2

1

nnnn

n

n

n

X

XXXXXX

XXXXXX

XXXXXX

X

X

X

X

symmetric is ),cov(),cov(

)var(),cov(

ijji

iii

XXXX

XXX

Page 24: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

24

Example: Multivariable Gaussian

• PDF of a vector X with a Gaussian joint distribution can be written:

parameterized by the vector mean µ and covariance matrix Σ (assumed positive definite, so det(Σ) > 0 and Σ−1 exists).

)()(exp)det()2(

1)( 1

xxxf T

N

Page 25: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

25

Random signals

• A random signal or a stochastic process x is a sequence of random variable x1, x2,…, xN with the index has the meaning of time step k.

• Observing the process for a certain interval of time yields a sequence of numbers or a record that is called a realization of the stochastic process.

• In system identification, signals (e.g., inputs, outputs) will often be stochastic processes evolving over discrete time steps k.

Page 26: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

26

Stationary Process

• Signal values at different time steps can be correlated (e.g. when they are the output of some dynamic system). Nevertheless, signals are usually required to be stationary, in the sense:

• Definition: the stochastic process is stationary if

• That is, the mean is the same at every step, whereas the covariance depends on only the relative positions of time steps, not their absolute positions. Often this is because the dynamics of the system generating the signal are invariant in time.

),cov(),cov(,,,

and,][E,

llkk

k

XXXXlk

Xk

Page 27: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

27

Ergodicity

• Ergodicity offers an empirical tool with which to derive an estimates of the expected values of a random signal, that in practice can be observed only via (a single) realization.

• For a stationary random signal {x(k)} = {x(1), x(2), …, x(N)}, the time average converges with probability unity to the mean value µx , provided that the number of observations N goes to infinity.

N

kN

x kxN 1

)(1

lim

Page 28: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

28

Covariance

• The covariance matrix of {x(k)} is

• The cross-covariance matrix of two discrete vector signals {x(k)} and {y(k)} is

N

k

Txx

N

Txx

kxkxN

kxkxx

1

))()()((1

lim

))()()((E)cov(

N

k

Tyx

N

Tyx

kykxN

kykxyx

1

))()()((1

lim

))()()((E),cov(

Page 29: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

29

Auto-correlation Function

• The autocorrelation function ruu(τ) of a stationary signal {u(k)} can be estimated as

• Where τ is the lag time.

• MATLAB function xcorr can be used to calculate the sample autocorrelation function.

N

iN

uu iuiuN

r1

)()(1

lim)(

Page 30: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

30

Zero-mean white noise• Let the stochastic process {e(k)} be a scalar sequence {e(1),

e(2), ...}. • The sequence {e(k)} is zero-mean white noise if it is serially

uncorrelated, that is

• White noise is one of the most significant signals in system identification.

lk

lkleke

kke

0)()(E

0)(E2

Values at different time steps are uncorrelated

Zero mean

Page 31: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

31

Example: White noise • A uniformly distributed white noise

sequence u, generated with the MATLAB function rand, is shown.

u = -0.5 + rand(125,1);

• Also shown is the associated normalized autocorrelation function, that is, ruu(τ)/ruu(0) for τ = 0,1,2,… calculated using xcorr(u).

• The autocorrelation function indicates that only at zero lag the autocorrelation is significant.

Page 32: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

32

Cross-correlation function

In addition to the autocorrelation function, the cross-correlation function ruy(τ) between two different signals {u(k)} and {y(k)} is defined as

N

iN

uy iyiuN

r1

)()(1

lim)(

Page 33: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

33

Example

Consider two random sequences S(k) and R(k), k=1,…,1000 formed using Matlab commands as follows:

>> S = 3*randn(1000, 1) + 10;>> R = 6*randn(1000, 1) + 20;

Page 34: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

34

Questions

1. What is the approximate mean value of each signal?

2. What is the empirical variance of each signal?

3. What is the empirical covariance matrix of a vector sequence

.1000,,2,1,)(

)()(

k

kR

kSkZ

Page 35: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

35

Using Matlab, we can calculate the empirical mean values and covariances of the signals:

mS = 9.9021 mR = 20.2296

covS = 8.9814 covR = 36.3954

covZ = [ 8.9814 0.5103 0.5103 36.3954]

mS = mean(S) mR = mean(R)

covS = cov(S) covR = cov(R)

Z = [S R]; covZ = cov(Z)

Answer

Page 36: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

36

NOTE

It is highly recommended to write your own code to calculate the variance, covariance and correlation functions instead of using only MATLAB built-in functions.

Page 37: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

37

Pseudo Random Binary sequence

Although white noise (for which ruu(τ) = 0 for τ≠0) are very important in system identification, in practice, using a Gaussian white noise input {u(k)} still has some restrictions:

Using a Gaussian distribution, very large input values may occur, which cannot be implemented due to physical restrictions.

Also, a signal from a genuinely random noise source

is not reproducible.

Page 38: Random Variables 1. Introduction In the measurement process, the presence of random variables and signals are inevitable. Therefore, the study of system

38

Pseudo Random Binary sequence• Therefore, amplitude constrained signals

such as a uniformly distributed signal are preferred in practice.

• A more practical choice is the PRBS which is a signal that switches between two discrete values, generated with a specific algorithm.

• The autocorrelation function of PRBS approximates that of the white noise.

• MATLAB command: u = idinput(N,'prbs')