Frequentist decision theory scores an estimator by its risk , here for samples from . An estimator is a dict:
{"name": "mean"}: the sample mean;{"name": "median"}: the sample median (numpy.median);{"name": "const", "theta0": t0}: always returns ;{"name": "postmean", "kappa": k, "theta0": t0}: the posterior mean under the prior , .Implement:
risk_closed_form(est, theta_star, N, sigma=1.0): for the mean, the large-sample value for the median, for the constant, and for the posterior mean.risk_mc(est, theta_star, N, n_rep, seed, sigma=1.0): draw X = theta_star + sigma * rng.standard_normal((n_rep, N)) with rng = np.random.default_rng(seed), apply the estimator to each row, and return the mean squared error.bayes_risk(est, N, tau, sigma=1.0, prior_mean=0.0): the average of risk_closed_form over , in closed form.minimax_index(ests, N, theta_grid, sigma=1.0): the index of the estimator whose largest closed-form risk over theta_grid is smallest (lowest index on ties).Return floats (an int for the index).