#!/usr/bin/env python # coding: utf-8 # # Week 12: Estimation # # # # #### [Back to main page](https://petrosyan.page/fall2020math3215) # # In[6]: # nbi:hide_in import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = (10, 5) n=100 #number of samples # intsize the number of class intervals class_num = 20 mean = 2 sigma = 3 mean0 = 0 sigma0 = 1 data = np.random.randn(n) * sigma + mean MLEmean = np.mean(data) MLEvar = np.var(data) tau2 = 1/(1/sigma0**2 + n/sigma**2) Bmean = tau2 * ((1/sigma0**2) * mean0 + (n/sigma**2) * MLEmean) # In[7]: MLEmean # In[8]: MLEvar # In[ ]: # nbi:hide_in import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = (10, 5) n=100 #number of samples # intsize the number of class intervals class_num = 20 mean = 2 sigma = 3 mean0 = 0 sigma0 = 1 data = np.random.randn(n) * sigma + mean MLEmean = np.mean(data) MLEvar = np.var(data) tau2 = 1/(1/sigma0**2 + n/sigma**2) Bmean = tau2 * ((1/sigma0**2) * mean0 + (n/sigma**2) * MLEmean)