16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde Lecture 5 Last time: Characterizing groups of random variables Names for groups of random variables n S = ∑ X i i=1 n n 2 S = ∑∑ X X ji i=1 j=1 Characterize by pairs to compute ∞ ∞ E XY ] = XY = dx xyf xy (, )x y dy [ ∫∫ , ?∞ ?∞ which we define as the correlation. Often we do not know the complete distribution, but only simple statistics. The most common of the moments of higher ordered distribution functions is the covariance, ? )( ? )(μ xy = E ?( X ? XY ? Y )?= ( X ? XY ? Y ) = XY ? XY ? XY + XY = XY ? XY ? XY + XY = XY ? XY = (correlation) ? (product of means) Even more significant is the normalized covariance, or correlation coefficient: μ xy ρ = μ 2 xy 2 = σσ , ? 1 ≤ ρ ≤ 1 σσ x y x y This correlation coefficient may be thought of as measuring the degree of linear dependence between the random variables: ρ = 0 if the two are independent and ρ =±1 if one is a linear function of the other. First note ρ = 0 if X and Y are independent. Calculate ρ for Ya=+ bX . xy If linearly related: Page 1 of 9 x 2 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde aY =+bX XY = a X +b X 2 Y 2 2 2 = a +2abX +b X 2 aX +b X 2 ? X (a +bX ) ρ = 2 2 2 2 2 2 2 )σ (a +2abX +b X ? ? 2abX ?b X a bX 2 ? X 2 ) 2 = ( = bσ x =±1sgn(b) = 2 22 ( 2 bσ x σ bX ? X 2 )x Degree of Linear Dependence At every observation, or trial or the experiment, we observe a pair x,y. We ask: how well can we approximate Y as a linear function of X? aY =+bX approx . 2 Choose a and b to minimize the mean squared error, ε , in the approximation. aε =Y ?Y =+ bX ?Y approx . 2 2 2 2 ε = a +b X + + 2abX ?2bXY ?2aY Y 2 2 Y 2 = a +b X 2 + + 2abX ?2b XY ?2aY Page 2 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde 2 ?ε = 2a +2bX ?2Y = 0 ?a 2 ?ε 2 = 2bX +2aX ?2XY = 0 ?b 2 2 2 ?ε ? X ?ε = (2b X 2 ?2XY ) ?(2bX ?2XY ) = 0 ?b ?a b = XY ? XY μ xy σ y = =ρ 2 X ? X 2 σ x 2 σ x aY μ xy σ y Y=? 2 X =?ρ X σ σ x x Y =? μ xy X + μ xy X approx . Y σ 2 2 σ x x Y μ xy =+ 2 ( X ? X ) σ x y Y=+ρ σ ( X ? X ) σ x y Y Y σ X ) ε =Y ?=+ρ ( X ? ? Y approx . σ x ε = 0 2 ( 2 2 2 ε = aa +2bX ?2Y ) +b X + ? 2b XY Y (Y Y 2 μ xy = ? μ xy X )(Y ? μ xy X +2 μ xy X ?2Y ) + μ xy X 2 + ? 2 XY 2 2 2 2 2 σ σ σ σ σ x x x x x Y 2 μ xy μ xy 2 μ xy 2 2 =? + 2 XY + μ xy XY ? 2 X + X + ? 2 μ xy XY 2 2 Y 2 σ σ σ σ σ x x x x x 2 =σ ?2 μ xy μ xy + μ xy 2 σ 2 y 2 4 x σ σ x x 2 ? 2 2 =σ ? μ xy 2 =σ y ? ? 1? μ xy 2 ? y 2 ? σ x ? σ x σ y 2 ? ? 2 (1? 2 =σ ρ ) y Page 3 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde If X and Y were actually linearly If X and Y were independent, the related, the points would appear on points would scatter all over the x,y one straight line, ρ would be ±1 , and plane, μ xy would be zero, so the mean squared error in the Y =Y , and ε 2 =σ y 2 . approx . approximation would be zero. Note that dependence other than linear is not necessarily measured by ρ. 2 3 Example: Y = X and X = X = 0 . 2 μ xy = XY = XY = X 3 ? X X = 0 →=0, but XY are dependent! ρ , Also, high correlation does not imply cause and effect. Example: Dying in the hospital. A survey reports that two events, “entering the hospital” and “dying within 1 week” have a high correlation. This relationship, however, is not causal. There exists a third, unreported event, “disease,” which causes each of the other events. Page 4 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde Vector-Matrix Notation Define the vectors X and x and the mean E X ] . [ ∞ ∞ E X dx 1 ... dx xf ( x) n n [] = ∫ ∫ ?∞ ?∞ ?? ∞ ∞ x 1 dx 1 ... dx ?? f ( x) M n = ∫ ∫ n ?? ?∞ ?∞ x?? n?? = X ? ? X 1 ? ? = M ? ? ? ? X n ?? Correlation Matrix T ?E XX T ? ? = XX = M ? M ij = X X ji So the correlation matrix arrays all the correlations among the X i with the mean squared values on the diagonal. Note that: ? The correlation matrix is symmetric. ? If X i and X j are independent, the correlation is the product of the means (from the product rule for the pdf). X i X j = X X ji Covariance Matrix T T T T T XE ?( X ? X )( X ? X ) ?= E ?XX ?? E X ]X ? XE ? ?+ XX ? ? ? ? [ ?? T T ?= E XX T ? ? ? XX ? XX T + XX ? T = XX T ? XX ≡ C T C ij =?( X ? X )( X ? X ) ? ? ij ? = XX j ? XX ji i This is by definition the covariance between X i and X j . So the covariance matrix arrays all the covariances among the X i with the variances along the diagonal. Page 5 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde If X i and X j are independent, their covariance is zero. If the covariance between two variables is zero, they are said to be uncorrelated. This does not, in general, imply that they are independent. Conditional Distribution Sometimes the notion of a conditional distribution is important. If we wish to confine our attention to the subject of cases in which an event E occurs, we would define the conditional probability distribution function: Fx ( | ( |()= F x E ) = PX ≤ x E ) E ( ,PX≤ xE ) = ()PE and the conditional probability density function: dF x E ()= f x E ) = () fx ( | E dx Application of Bayes’ Rule Bayes’ theorem can be written for the distribution of a random variable conditioned on the occurrence of an event E or the observation of a certain value of another random variable. Conditioned on an event E: ( | ()(| k k Original form: PA E ) = PA PE A ) k ()( | ∑ PA PE A ) i i i xLet the events A i → the events x < X ≤+ dx Note that for different values x as dx → 0 these events are mutually exclusive and collectively exhaustive. ( | ) () ( | lim fx Edx= ∞ f xdxPE x ) dx→0 () ( | )f uPE udu ∫ ?∞ (| ()( | fx E ) = fxPE x ) ∞ () ( | )f uPE udu ∫ ?∞ Page 6 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde Example: Measuring the position of a spacecraft far away Measurement: yxn =+, where n is noise. E implies y lies in a quantized interval. It is simple to use this interval to estimate y, but not correct. y y y E? < ≤ 2 1 y xn y <+≤ 2 1 y xn y x ?<≤ ? 1 2 We update the unconditional distribution for x to the conditional distribution for x. This is the right way. Page 7 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde Conditioned on a value of Y: Let the event E be the event yY ydy < ≤+ . E will be the value taken by y (like a measurement variable). ( | () ( | lim fxy ) = f xfyx)dy dy→0 ∞ f u f y u)dydu() ( | ∫ ?∞ Note: y is not the variable of integration. ( | () ( | fxy ) = fxfyx ) ∞ () ( |f uf yu)du ∫ ?∞ This provides a basis for the estimation of a parameter X based on prior information, f(x), and measurements y which are related to X. Example: yx n n y x =+ =? parameterizing x (| ( ?f yx) = f y x ) n We assume n is independent of x. (|f yx) is the noise distribution shifted by x. Conditional Expectation The conditional expectation of a random variable or function of a random variable is the expectation calculated with the conditional distribution. ∞ [ ()| () ( | )Egx A ]= gxfxAdx ∫ ?∞ A useful relation involving conditional expectations is Egx ( ) [ ( ) | [ () ] = ∑ PAEgX A ] i i i if the A i are mutually exclusive and exhaustive. Or, if we let the events A i be the events yY yd<≤+ y , Page 8 of 9 16.322 Stochastic Estimation and Control, Fall 2004 Prof. Vander Velde ∞ [ () ] = Egx | y f ydyEgx [ () ] ( ) ∫ ?∞ The conditional expectation of a random variable, E [ xy] , is often taken as the | estimate of the random variable after incorporating the effect of a measured event or related random variable. f (xE,..., E ) : State of knowledge about x given observations E 1 ,…,E n | 1 n f (xy,..., y ) : State of knowledge about x given measurements y 1 ,…,y n | 1 n Probability Distribution of Functions of Random Variables The probability distribution and density for functions of random variables can be calculated from the distributions of the variables themselves. (, ()In general, if Z = gXY ) and we want f z , we can use z Fz (()= PZ ≤ z) z [ (,= PgXY ) ≤ z ] dx dy f xy (,x y )= ∫∫ , to get the distribution function for all values of z. dF z z fz()= () z dz In particular cases, there may be easier ways to do this, but this is the general procedure. Page 9 of 9