From f28366c82175c356576f550ee1bff7b516a5dd42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Delfino?= Date: Wed, 18 Jul 2018 10:52:12 -0300 Subject: [PATCH] bpo-34147: Describe briefly sampling w/out replacement in random --- Doc/library/random.rst | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 4f251574a32726..fd26f159f3cf80 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -14,7 +14,7 @@ distributions. For integers, there is uniform selection from a range. For sequences, there is uniform selection of a random element, a function to generate a random permutation of a list in-place, and a function for random sampling without -replacement. +replacement [1]_. On the real line, there are functions to compute uniform, normal (Gaussian), lognormal, negative exponential, gamma, and beta distributions. For generating @@ -141,7 +141,7 @@ Functions for sequences .. function:: choices(population, weights=None, *, cum_weights=None, k=1) - Return a *k* sized list of elements chosen from the *population* with replacement. + Return a *k* sized list of elements chosen from the *population* with replacement [1]_. If the *population* is empty, raises :exc:`IndexError`. If a *weights* sequence is specified, selections are made according to the @@ -185,7 +185,7 @@ Functions for sequences .. function:: sample(population, k) Return a *k* length list of unique elements chosen from the population sequence - or set. Used for random sampling without replacement. + or set. Used for random sampling without replacement [1]_. Returns a new list containing elements from the population while leaving the original population unchanged. The resulting list is in selection order so that @@ -389,7 +389,7 @@ Simulations:: Example of `statistical bootstrapping `_ using resampling -with replacement to estimate a confidence interval for the mean of a sample of +with replacement [1]_ to estimate a confidence interval for the mean of a sample of size five:: # http://statistics.about.com/od/Applications/a/Example-Of-Bootstrapping.htm @@ -477,3 +477,10 @@ Simulation of arrival times and service deliveries in a single server queue:: a tutorial by `Peter Norvig `_ covering the basics of probability theory, how to write simulations, and how to perform data analysis using Python. + + +.. rubric:: Footnotes + +.. [1] Sampling can be done with or without replacement. Sampling with + replacement may select the same element more than once, while sampling + without replacement will not select the same element more than once.