MATH 351 Homework 05

In this homework we will simulate NN random variables, each of which is from the same distribution you worked with in Homework 02, let's call this distribution XX. Convergence in probability dictates that the mean of arbitrary continuous functions gg of the random variables g(X1),,g(XN)g(X_1), \ldots, g(X_N) converges in probability (not smoothly) to the expectation E[g(X)]\mathbb{E}[g(X)]. You should use only one for-loop, of length NN, for this entire assignment.

  1. Generate N=10,000N = 10,000 random variables from your distribution with fixed parameters, similar to Homeworks 02 and 03. Store these data in a variable named x.
  2. Create at least two, maybe three if you have more than one chosen parameter from part 1., instances of the class OnlineMoments(). Each instance should have a variable name appropriate for the expectation it's going to be tracking: mean and variance, first parameter, (maybe second parameter).
  3. For N=10,000N = 10,000, set up a for-loop that does the following each iteration:
    1. update each instance of OnlineMoments() -- what you update with will vary, the mean and variance are updated with simply each data point, but to update your parameters you need to use the function of the mean and variance you developed in Homework 02;
    2. store the nnth mean, variance, and estimate of your parameter(s);
  4. Make one convergence in probability plot for each of the stored estimates: mean, variance, and estimated parameter(s). On each plot you should draw in a horizontal, dashed black line the true value you are trying to estimate.
  5. Write out LaTeX\LaTeX code as a Text cell the explains what calculations are going on in the code. As an example, here's what you all should have for the mean N1n=1NXnPE[X]N^{-1}\sum_{n=1}^N X_n \to_{\mathbb{P}} \mathbb{E}[X]