Raymond Hettinger added the comment: ################################################################### # Flipping a biased coin
from collections import Counter from random import choices print(Counter(choices(range(2), [0.9, 0.1], k=1000))) ################################################################### # Bootstrapping 'From a small statistical sample infer a 90% confidence interval for the mean' # http://statistics.about.com/od/Applications/a/Example-Of-Bootstrapping.htm from statistics import mean from random import choices data = 1, 2, 4, 4, 10 means = sorted(mean(choices(data, k=5)) for i in range(20)) print('The sample mean of {:.1f} has a 90% confidence interval from {:.1f} to {:.1f}'.format( mean(data), means[1], means[-2])) ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18844> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com