Throughout, set \(R = 1001\) and use both \(N = 17\) and \(N = 385\) in separate runs.

  1. Assume the population is Gamma, with \(\alpha, \beta > 0\) of your choice.

    1. Pre-allocate an array of size \(R\).

    2. Generate \(N\) Gamma random variables. Use the function \(\texttt{numpy.random.gamma}(\alpha, \beta, N)\). Name this array X.

    3. In a for loop of length \(R\),
      • randomly choose elements of X with replacement, then estimate the population median with them. Store the estimate into the \(r\)th element of your pre-allocated array.
    4. Estimate the population standard deviation of the sample median using your array of sample medians.

    5. What is the name of this quantity?

    6. Explain, in complete English sentences, what the standard deviation of the sample median is telling us.

    7. Make a density plot using the array of sample medians.

    8. What is the name of this density function?

    9. Repeat steps a. through h. using the other sample size, overlaying the two density plots on each other. Use the color and label arguments of bp.density() to differentiate the two density curves on the same plot. Call bp.legend() after your done plotting.

    10. Explain, in complete English sentences, why your two density curves look different.

  2. Double secret sauce extra bonus challenge. Assume the population is Normal, with \(\mu\) a real number and \(\sigma > 0\) of your choice.
    1. Pre-allocate an array of size \((R, 2)\).

    2. Generate \(N\) Normal random variables. Use the function \(\texttt{numpy.random.normal}(\mu, \sigma, N)\). Name this array X.

    3. In a for loop of length \(R\),
      • create an array of randomly chosen integers from \(0\) to \(N - 1\), with replacement. Name this array idx.
      • use Scipy’s function minimize to estimate the population mean and standard deviation, using the array of random variables just generated. Instead of passing in X, pass in X indexed with idx, as your data. Store the estimate into the \(r\)th element of your pre-allocated array.
    4. Estimate the population standard deviation of the array of each sample statistic.

    5. What is the name of these quantities? Hint: They can’t have the same name, they differ by what they are the standard deviation of.

    6. Explain, in complete English sentences, what the standard deviation of each of the sample statistics is telling us.

    7. Make a plot density plot using the array of each sample statistic.

    8. What is the name of these density functions? Hint: They can’t have the same name, they differ by what they are the standard deviation of.

    9. Repeat steps a. through h. using the other sample size for each sample statistic, overlaying the two density plots on each other. Use the color and label arguments of bp.density() to differentiate the two density curves on the same plot. Call bp.legend() after your done plotting.

    10. Explain, in complete English sentences, why your two density curves look different.