# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

# + [markdown] toc=true
# <h1>Sumário<span class="tocSkip"></span></h1>
# <div class="toc"><ul class="toc-item"></ul></div>
# -

# # 4 You are given two random variables X and Y.
# - E(X) = 0.5, Var(X) = 2
# - E(Y) = 7, Var(Y) = 3.5
# - cov (X, Y) = -0.8 
#
# Find the variance of the random variable Z = 2X - 3Y.

# $(1)\operatorname {Var}(Z)=\operatorname {E}(Z^2)-\operatorname {E}(Z)^2$

# first term:
#
# $\operatorname {E}(Z)=\operatorname {E}[(2X-3Y)]$ =
# $\operatorname {E}(2X)-\operatorname {E}(3Y)$ = 
#
# $2\operatorname {E}(X)-3\operatorname {E}(Y)$ = $2*0.5-3*7 = -20$

# Second term:
#
# $\operatorname {E}(Z^2)=\operatorname {E}[(2X-3Y)^2]$
#
# $\operatorname {E}(Z^2)=\operatorname {E}[4X^2-12XY+9Y^2]$
#
# $\operatorname {E}(Z^2)=\operatorname {E}(4X^2)-\operatorname {E}(12XY)+\operatorname {E}(9Y^2)$
#
# $\operatorname {E}(Z^2)=4\operatorname {E}(X^2)-12\operatorname {E}(XY)+9\operatorname {E}(Y^2)$

# From variance and covariance definitions:
#
# $\operatorname {E}(X^2) = \operatorname {Var}(X)+\operatorname {E}(X)^2 = 2+0.25 = 2.25$
#
# $\operatorname {E}(Y^2) = \operatorname {Var}(Y)+\operatorname {E}(Y)^2 = 3.5+49 = 52.5$
#
# $\operatorname {E}(XY) = \operatorname {cov}(XY)+\operatorname {E}(X)\operatorname {E}(Y) = -0.8+7*0.5 = 2.7$

# Therefore:
# $\operatorname {E}(Z^2)=4*2.25-12*52.5+9*2.7=-617.5$

# take the equation (10):
#
# $(1)\operatorname {Var}(Z)=\operatorname {E}(Z^2)-\operatorname {E}(Z)^2$ = 
#
# **$(-20)^2-(-617.5) = 1017.5 $**  

# # Var(z) = 1017.5

#

#

#

StarcoderdataJupyterScriptsDedupFiltered