Homework 11

  • Type your name and email in the “Student details” section below.

  • Develop the code and generate the figures you need to solve the problems using this notebook.

  • For the answers that require a mathematical proof or derivation you can either:

    • Type the answer using the built-in latex capabilities. In this case, simply export the notebook as a pdf and upload it on gradescope; or

    • You can print the notebook (after you are done with all the code), write your answers by hand, scan, turn your response to a single pdf, and upload on gradescope.

  • The total homework points are 100. Please note that the problems are not weighed equally.

Note

  • This is due before the beginning of the next lecture.

  • Please match all the pages corresponding to each of the questions when you submit on gradescope.

Student details

  • First Name:

  • Last Name:

  • Email:

import matplotlib.pyplot as plt
%matplotlib inline
import seaborn as sns
sns.set(rc={"figure.dpi":100, 'savefig.dpi':300})
sns.set_context('notebook')
sns.set_style("ticks")
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('retina', 'svg')
import numpy as np
import scipy.stats as st

Problem 1 - Calculating expectations for discrete random variables

Consider the Categorical random variable \(X \sim \text{Categorical}(0.2, 0.4, 0.4)\) taking three discrete values \(1, 2,\) and \(3\). Find the numerical answer for the following. Hint: You can do it by hand or write some code. It is up to you.

  • \(\mathbf{E}[X] = ?\)

Answer:







# Your code here
  • \(\mathbf{E}[X^2] = ?\)

Answer:







# Your code here
  • \(\mathbf{V}[X] = ?\)

Answer:







# Your code here
  • \(\mathbf{E}[e^X] = ?\)

Answer:







# Your code here

Problem 2 - Calculate the expectation and variance of a continuous random variable

Take an exponential random variable, see Problem 2 of Homework 10, with rate parameter \(\lambda\):

\[ T \sim \text{Exp}(\lambda). \]

The PDF of the exponential is:

\[ p(t) = \lambda e^{-\lambda t}, \]

for \(t\ge 0\) and zero otherwise.

  • Prove mathematically that \(\mathbf{E}[T] = \lambda^{-1}\). Hint: You need to do the integral \(\int_0^\infty tp(t)dt\) using integration by parts.

Answer:







  • Prove mathematically that \(\mathbf{V}[T] = \lambda^{-2}\). Hint: Use integration by parts to find \(\mathbf{E}[T^2]=\int_0^\infty t^2 p(t)dt\) and then use one of the properties of the variance.

Answer:







Problem 3 - Properties of expectations

Let \(X\) be a random variable with expectation \(\mathbf{E}[X] = 3\) and variance \(\mathbf{V}[X] = 2\). Calculate the following expressions.

  • \(\mathbf{E}[4X] = ?\)

Answer:







  • \(\mathbf{E}[X + 2] = ?\)

Answer:







  • \(\mathbf{E}[3X + 1] = ?\)

Answer:







  • \(\mathbf{V}[5X] = ?\)

Answer:







  • \(\mathbf{V}[X + 3] = ?\)

Answer:







  • \(\mathbf{V}[2X + 1] = ?\)

Answer:







  • \(\mathbf{E}[X^2] = ?\)

Answer: