text: # bootstrap confidence intervals
  from numpy.random import seed
  from numpy.random import rand
  from numpy.random import randint
  from numpy import mean
  from numpy import median
  from numpy import percentile
  # seed the random number generator
  seed(1)
  # generate dataset
  dataset = 0.5 + rand(1000) * 0.5
  # bootstrap
  scores = list()
  for _ in range(100):
  	# bootstrap sample
  	indices = randint(0, 1000, 1000)
  	sample = dataset[indices]
  	# calculate and store statistic
  	statistic = mean(sample)
  	scores.append(statistic)
  print('50th percentile (median) = %.3f' % median(scores))
  # calculate 95% confidence intervals (100 - alpha)
  alpha = 5.0
  # calculate lower percentile (e.g. 2.5)
  lower_p = alpha / 2.0
  # retrieve observation at lower percentile
  lower = max(0.0, percentile(scores, lower_p))
  print('%.1fth percentile = %.3f' % (lower_p, lower))
  # calculate upper percentile (e.g. 97.5)
  upper_p = (100 - alpha) + (alpha / 2.0)
  # retrieve observation at upper percentile
  upper = min(1.0, percentile(scores, upper_p))
  print('%.1fth percentile = %.3f' % (upper_p, upper))
  