Last active
August 29, 2015 14:20
-
-
Save alyssafrazee/95f577cd37d3866eb1c7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from numpy.random import randint | |
from numpy import median, percentile | |
my_data = pd.read_csv('dataset.csv') | |
n = len(my_data) | |
num_bootstrap_samples = 1000 | |
bootstrap_results = [] | |
for b in xrange(num_bootstrap_samples): | |
sampled_data = my_data.iloc[randint(0, n, size=n)] | |
med = median(sampled_data['income']) | |
bootstrap_results.append(med) | |
ci_lower = percentile(bootstrap_results, 2.5) | |
ci_upper = percentile(bootstrap_results, 97.5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment