Example of bootstrapping the confidence interval for the mean of a sample distribution Since no bootstrapping is implemented in Python, this function requires "", which is included.

Note: The original scikits-bootstrapping module, which works only under Python 2, is available from

Author: Thomas Haslwanter, Date: Feb-2017

In [2]:
%matplotlib inline
import scipy as sp
import matplotlib.pyplot as plt
from scipy import stats
import scikits.bootstrap as bootstrap
In [3]:
# Generate a non-normally distributed datasample
data = stats.poisson.rvs(2, size=1000)

# Show the data
plt.plot(data, '.')
plt.title('Non-normally distributed dataset: Press any key to continue')
<matplotlib.text.Text at 0x27e6c3619e8>
In [4]:
# Calculate the bootstrap
CIs =, statfunction=sp.mean)

# Print the data: the "*" turns the array CIs into a list
print('The conficence intervals for the mean are: {0} - {1}'.format(*CIs))
The conficence intervals for the mean are: 2.001 - 2.179