Skip to content

Instantly share code, notes, and snippets.

@ychennay
Last active May 12, 2019 18:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ychennay/84c60cda78c5d3c32f9f51b9bb51c614 to your computer and use it in GitHub Desktop.
Save ychennay/84c60cda78c5d3c32f9f51b9bb51c614 to your computer and use it in GitHub Desktop.
true_median = np.median(X["Impressions"])
errors = []
variances = []
for b in range(1, 500):
sample_medians = [np.median(X.sample(len(X), replace=True)["Impressions"]) for i in range(b)]
error = np.mean(sample_medians) - true_median
variances.append(np.std(sample_medians) ** 2) # record the variance of the bootstrap estimates
errors.append(error)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment