Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Statistics 100A Homework 5 Solutions Ryan Rosario Problem 1 For a continuous variable X ∼ f (x). For each part, it is not sufficient to simply use the properties of expectation and variance. (1) Prove E[aX + b] = aE[X] + b. Proof. Z∞ E[aX + b] = (aX + b) f (x) dx −∞ Z∞ = Z∞ aXf (x) dx + −∞ −∞ Z∞ Z∞ = a bf (x) dx Xf (x) dx +b −∞ | f (x) dx −∞ {z =E(X) } | {z =1 } = aE[X] + b (2) Prove Var (aX + b) = a2 Var (X). Let Z = aX + b. Proof. Z∞ Var (Z) = −∞ Z∞ = −∞ Z∞ = −∞ Z∞ = (z − E(Z))2 f (x) dx 2 ax + b − aµ + b f (x) dx (ax − aµ)2 f (x) dx a2 (x − µ)2 f (x) dx −∞ 2 Z∞ = a (x − E[X])2 f (x) dx −∞ 2 = a Var (X) 1 (3) Prove Var (X) = E[X 2 ] − E[X]2 . Proof. Z∞ Var (X) = −∞ Z∞ = −∞ Z∞ = (x − µ)2 f (x) dx x2 + µ2 − 2xµ f (x) dx 2 x f (x) f (x) + µ −∞ 2 Z∞ Z∞ f (x) dx − 2µ −∞ 2 2 = E[X ] + µ − 2µ xf (x) dx −∞ 2 = E[X 2 ] − µ2 = E[X 2 ] − E[X]2 (4) Let µ = E[X], σ 2 = Var (X) and Z = Let Z = X−µ σ . Calculate E[Z] and Var (Z). X−µ σ . It is expected that you compute E(Z) and Var (Z) as follows Z∞ E[Z] = zf (z) dz −∞ Z∞ = x−µ σ f (x) dx −∞ = 1 σ Z∞ (x − µ)f (x) dx −∞ = ∞ Z Z∞ 1 xf (x) dx − µ f (x) dx σ −∞ −∞ 1 = (E(X) − µ) σ µ−µ = σ = 0 2 But it is also acceptable to use what we just proved. X −µ E[Z] = E σ 1 = E(X − µ) σ 1 = [E(X) − µ] σ 1 (µ − µ) = σ = 0 Similarly, Var (Z) = Var X −µ σ 1 Var (X) σ2 1 = · σ2 σ2 = 1 = Problem 2 For U ∼ U nif orm[0, 1], calculate E[U ], E[U 2 ], Var (U ), and F (u) = P (U ≤ u). By definition, the PDF for the uniform distribution is f (x) = a = 0 so f (x) = 1. Then, Z1 E(U ) = uf (u) du 0 Z1 = u du 0 = = 1 2 1 u 2 0 1 2 In general, for U ∼ Uniform[a, b], E(U ) = 3 b−a 2 1 b−a . In this problem, b = 1 and E U 2 Z1 = u2 f (u) du 0 Z1 = u2 du 0 1 3 1 u 3 0 1 3 = = Then Var (U ) = E U 2 − E(U )2 2 1 1 − = 3 2 1 1 = − 3 4 1 = 12 and in general, for U ∼ Uniform[a, b], Var (U ) = b−a 12 Problem 3 For T ∼ Exp(λ), (1) Calculate F (t) = P (T ≤ t). For a > b > 0, f indP (T > a|T > b). By definition F (t) = P (T ≤ t) Zt = λe−λt dt 0 Zt = λ e−λt dt 0 1 −λt t = λ − e λ 0 −λt = − e −1 = 1 − e−λt Thus, we can also see that P (T > t) = e−λt . 4 (2) Calculate E[T ] and Var (T ). By definition Z∞ E(T ) = tλe−λt dt 0 Z∞ = λ te−λt dt 0 = = = = = = Use integration by parts, u = t, dv = e−λt and the IBP formula uv − Z 1 −λt 1 −λt λ t − e − − e dt λ λ Z 1 −λt 1 −λt λ t − e + e dt λ λ ∞ 1 1 1 − e−λt λ t − e−λt + λ λ λ 0 1 −λt 1 −λt ∞ λ t − e − 2e λ λ 0 ∞ 1 −te−λt − e−λt λ 0 ∞ 1 −λt −e t+ λ 0 Note that to evaluate at ∞, we take the limit and that lim −e −λt t→∞ 1 t+ =∞·0 λ which is an indeterminate form, but we can do t + λ1 eλt lim − t→∞ ! = ∞ ∞ another indeterminate form, but now we can use L’Hopital’s Rule yielding 1 =0 t→∞ λeλt lim Then, −λt −e ∞ 1 1 1 t+ =0− − = λ λ λ 0 5 R v du. Now we compute Var (T ). Recall that Var (T ) = E T 2 − E(T )2 . We find E(T 2 ). E T 2 Z∞ = t2 λe−λt dt 0 Z∞ = λ t2 e−λt dt 0 R By integration by parts, u = t2 , dv = e−λt and the IBP formula uv − v du. Z ∞ 1 −λt 1 2 −λt − − · 2t · e = λ t − e dt λ λ 0 ∞ Z t2 −λt 2 + te−λt dt = λ − e λ λ ∞ 0 Z = −t2 e−λt + 2 te−λt dt 0 R By ingration by parts, u = t, dv = e−λt and the IBP formula uv − v du. ∞ Z 1 −λt 1 −λt 2 −λt − − e dt = −t e +2 t − e λ λ 0 ∞ Z 1 t e−λt dt = −t2 e−λt + 2 − e−λt + λ λ 0 ∞ t 1 1 2 −λt −λt −λt = −t e +2 − e + − e λ λ λ 0 ∞ t 1 = −t2 e−λt + 2 − e−λt − 2 e−λt λ λ 0 ∞ 2 2t = −t2 e−λt − e−λt − 2 e−λt λ λ ∞ 0 2t 2 = −e−λt t2 + + 2 λ λ 0 2t 2 lim −e−λt t2 + + 2 =0·∞ t→∞ λ λ which is indeterminate and can be arranged to a friendlier indeterminate form lim − t2 + t→∞ 2 2t λ + λ2 eλt = L’Hopital’s Rule then yields lim − t→∞ 2t + λ2 ∞ = λt ∞ λe So we use L’Hopital’s Rule again, which yields lim − t→∞ 6 2 λ2 eλt =0 ∞ ∞ So we get E T 2 = −e −λt 2t 2 t + + 2 λ λ 2 ∞ 2 = 0− − 2 = 2 2 λ λ 0 Var (T ) = E T 2 − E(T )2 2 2 1 = − 2 λ λ 1 2 − = λ2 λ2 1 = λ2 (3) If U ∼ Uniform[0, 1], let X = − logλ U . Calculate F (x) = P (X ≤ x), and f (x) = F (x). What is the distribution of X? To find the distribution of X, we need to find fX (x). We do this by starting with the CDF of x and differentating it with respect to x. FX (x) = P (X ≤ x) log U = P − ≤x λ = P (log U ≥ −λx) = P U ≥ e−λx = 1 − P U ≤ e−λx But notice that P U ≤ e−λx is the CDF for U , FU (u). = 1 − FU e−λx Recall from an earlier problem that the CDF for the uniform distribution is FU (u) = u, so replace u with e−λx . = 1 − e−λx And notice that the above is the CDF for the exponential distribution. To get the distribution of X, differentiation w/r/t x. f (x) = λeλx which is the PDF f (x) for the exponential distribution with parameter λ, thus X ∼ Exp (λ). 7 (4) Let Y = aT where a > 0. What is the density function of Y ? Again, to get f (y), we start with the CDF of Y , FY and then differentiate it with respect to y. 4FY (y) = P (Y ≤ y) = P (aT ≤ y) y = P T ≤ a which is the CDF for T w/r/t y, FT (y). y = FT a Now differentiate with respect to y. y d y = fT · a dy a 1 y = fT a a where fT (t) = λe−λt λy 1 · λe− a = a λ −( λ )y = e a a Thus Y ∼ Exp λa . Problem 4 Suppose Z ∼ N (0, 1). The density of Z is z2 1 f (z) = √ e− 2 2π (1) Calculate E[Z] and Var[Z]. By definition, Z∞ E(Z) = −∞ z2 z √ e− 2 dz 2π If we pull out the annoying constant, we get 1 E(Z) = √ 2π 8 Z∞ −∞ ze− z2 2 dz Trick: Note that the function ze is odd, then z2 2 is an odd function. Recall from Math 31B that if f (x) Za f (x) dx = 0 −a Thus, E(Z) = 0. Recall that Z∞ Var (Z) = −∞ z2 1 1 (z − E(Z)) · √ e− 2 dz = √ 2π 2π 2 We integrate by parts. Let u = z, dv = ze 1 √ 2π Z∞ z2 · e 2 − z2 −∞ But note that since ze− z2 2 −z 2 2 Z∞ z 2 · e− z2 2 dz −∞ . Then, Z∞ 2 2 z z 1 dz = √ [ − ze− 2 ]∞ + e− 2 dz −∞ 2π −∞ z2 is odd, [ − ze− 2 ]∞ −∞ = 0. So we are left with Z∞ Var (Z) = −∞ z2 1 √ e− 2 dz 2π But note that the integrand is the standard normal distribution! This means that when integrated over its domain (infinite), the integral is 1! So Var (Z) = 1. (2) Let X = µ + σZ. What are E[X] and Var (X)? What is the density function of X? Please! One at a time! No pushing... Let’s start with E[X]. Since X = µ + σZ, E(X) = E(µ + σZ) = E(µ) + E(σZ) = µ + σE(Z) = µ And, Var (X) = Var (µ + σZ) = σ 2 Var (Z) = σ2 9 Now the hard part. We want to find the density function of X. There is a theorem that you will learn in 100B that is related to this problem. That theorem states that if Z is a standard normal random variable (Z ∼ N (0, 1)), then X = µ + σZ is also a normal random variable. We just proved that the mean is µ and the variance is σ. What we have not proven is that the distribution of X is normal... yet. We start with the CDF of and then differentiate it to get the density function f (x). In my notation below, FX denotes that we are finding the CDF of X. FX (x) = P (X ≤ x) = P (µ + σZ ≤ x) x−µ = P Z≤ σ x−µ Zσ z2 1 √ e− 2 dt 2π −∞ x−µ = FZ σ = Now we have that FX (x) = FZ distribution of Z. x−µ σ where FZ is the cumulative distribution function of the Recall that we want to differentiate FX (x) so that we get fX (x) (which is the density funcx−µ tion), but since FX (x) = FZ σ , differentiating FX is the same as differentiating FZ . Is everybody with me? So we proceed as follows. d x−µ FZ dx σ x−µ d x−µ = fZ σ dx σ where is the chain rule. the above x−µ 1 = fZ · σ σ 1 x−µ = · fZ σ σ d FX (x) = dx Recap: Before concluding, let’s review what we have calculated so far... d 1 FX (x) = fX (x) = · fZ dx σ But recall that z2 1 fZ (z) = √ e− 2 2π 10 x−µ σ So fZ x−µ σ 1 x−µ 2 1 = √ e− 2 ( σ ) 2π Thus, 1 fX (x) = · fZ σ x−µ σ 1 x−µ 2 1 =√ e− 2 ( σ ) 2πσ Cool, eh? Problem 5 Suppose we flip a fair coin 1000 times independently. Let X be the number of heads. Answer the following questions using normal approximation. Note that we would usually solve this problem using the binomial. The computation would be cumbersome, but more importantly, since p = 21 is not too close to 0 or 1, and n is large, and since np > 10, n(1 − p) > 10, we use the normal approximation to the binomial. Since the binomial distribution is discrete and the normal distribution is continuous, we must use a correction. Using the normal approximation, we have that µ = np = 250. 1000 2 = 500 and σ 2 = np(1 − p) = 500 · 12 = (1) What is the probability that 480 ≤ X ≤ 520? P (480 ≤ X ≤ 520) ≈ P (479.5 ≤ X ≤ 520.5) 479.5 − 500 520.5 − 500 √ √ = P ≤Z≤ 250 250 = P (−1.3 ≤ Z ≤ 1.3) = P (Z ≤ 1.3) − P (Z ≤ −1.3) ≈ 0.794 Note that the range around the mean is symmetric so it is also true that P (Z ≤ 1.3) − P (Z ≤ −1.3) = 1 − 2P (Z ≤ −1.3) = 0.794 (2) What is the probability that X > 530? P (X > 530) = 1 − P (X ≤ 530) ≈ 1 − P (X ≤ 529.5) 529.5 − 500 √ = 1−P Z ≤ 250 = 1 − P (Z ≤ 1.87) ≈ 0.031 11 Problem 6 Suppose among the population of voters, 31 of the people support a candidate. If we sample 1000 people from the population, and let X be the number of supporters of this candidate among these 1000 people. Let p̂ = X/ n be the sample proportion. Answer the following questions using normal approximation. = 0.0002 . Note that by the Central Limit Theorem, p̂ ∼ N p, p(1−p) n (1) What is the probability that p̂ > .35 0.35 − 0.33 P (p̂ > 0.35) = P p̂ > √ 0.0002 = 1 − P (Z ≤ 1.41) = 0.079 (2) What is the probability that p̂ < .3? 0.3 − 0.33 √ P (p̂ < 0.3) = P Z < 0.0002 = P (Z < −2.12) = 0.017 Problem 7 Consider the following joint probability mass function p(x, y) of the discrete random variables (X, Y ): x/y 1 2 3 1 0.1 0.2 0.1 2 0.1 0.1 0.05 3 0.1 0.2 0.05 (1) Calculate pX (x) for x = 1, 2, 3. Calculate pY (y) for y = 1, 2, 3. Note that pX (x) is the marginal of X and is just the row sums, thus, pX (1) = 0.1 + 0.1 + 0.1 = 0.3 pX (2) = 0.2 + 0.1 + 0.2 = 0.5 pX (3) = 0.1 + 0.05 + 0.05 = 0.2 Note that pY (y) is the marginal of Y and is just the column sums, thus pY (1) = 0.1 + 0.2 + 0.1 = 0.4 pY (2) = 0.1 + 0.1 + 0.05 = 0.25 pY (3) = 0.1 + 0.2 + 0.05 = 0.35 12 (2) Calculate P (X = x|Y = y) and calculate P (Y = y|X = x) for all pairs of (x, y). By Bayes’ Rule, P (X = x|Y = y) = p(x, y) P (Y = y) P (Y = y|X = x) = p(x, y) P (X = x) Thus, P (X = x|Y = y): x/y 1 2 3 1 0.25 0.5 0.25 2 0.4 0.4 0.2 3 0.286 0.57 0.143 x/y 1 2 3 1 0.33 0.4 0.5 2 0.33 0.2 0.25 3 0.33 0.4 0.25 Thus, P (Y = y|X = x): (3) Calculate E(X) and E(Y ). Calculate Var (X) and Var (Y ). E(X) = 1 · P (X = 1) + 2 · P (X = 2) + 3 · P (X = 3) = 0.3 + 2 · 0.5 + 3 · 0.2 = 1.9 E(Y ) = 1 · P (Y = 1) + 2 · P (Y = 2) + 3 · P (Y = 3) = 0.4 + 2 · 0.25 + 3 · 0.35 = 1.95 Var (X) = (1 − 1.9)2 · 0.3 + (2 − 1.9)2 · 0.5 + (3 − 1.9)2 · 0.2 = 0.49 Var (Y ) = (1 − 1.95)2 · 0.4 + (2 − 1.95)2 · 0.25 + (3 − 1.95)2 · 0.35 = 0.7475 13 (4) Calculate E(XY ). Calculate Cov(X, Y ). Calculate Corr(X, Y ). Note that E(XY ) = E(X)E(Y ) if and only if X and Y are independent. E(XY ) = XX x p(x, y) y = 1 · 1 · p(1, 1) + 1 · 2 · p(1, 2) + 1 · 3 · p(1, 3) 2 · 1 · p(2, 1) + 2 · 2 · p(2, 2) + 2 · 3 · p(2, 3) 3 · 1 · p(3, 1) + 3 · 2 · p(3, 2) + 3 · 3 · p(3, 3) = 0.1 + 2 · 0.1 + 3 · 0.1 + 2 · 0.2 + 4 · 0.1 + 6 · 0.2 3 · 0.1 + 6 · 0.05 + 9 · 0.05 = 3.65 By definition, Cov(X, Y ) = E(XY ) − E(X)E(Y ). Cov(X, Y ) = E(XY ) − E(X)E(Y ) = 3.65 − 1.9 · 1.95 = −0.055 Since the covariance is not 0, X and Y are dependent. They have a negative relationship. Since the covariance can be anything, we normalize to get a value between -1 (perfect negative correlation), and +1 (perfect positive correlation) where 0 means no correlation. Cov(X, Y ) σx σy Cov(X, Y ) p = p Var (X) Var (Y ) −0.055 √ = √ 0.49 0.7475 = −0.091 Corr(X, Y ) = X and Y have a weakly negative correlation. 14