[Python-checkins] python/dist/src/Doc/lib librandom.tex,1.30,1.31
rhettinger@users.sourceforge.net
rhettinger@users.sourceforge.net
Tue, 12 Nov 2002 09:41:59 -0800
Update of /cvsroot/python/python/dist/src/Doc/lib
In directory usw-pr-cvs1:/tmp/cvs-serv10733/Doc/lib
Modified Files:
librandom.tex
Log Message:
SF patch 629637: Add sample(population, k) method to the random module.
Used for random sampling without replacement.
Index: librandom.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/lib/librandom.tex,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** librandom.tex 23 May 2002 21:07:19 -0000 1.30
--- librandom.tex 12 Nov 2002 17:41:57 -0000 1.31
***************
*** 180,183 ****
--- 180,202 ----
\end{funcdesc}
+ \begin{funcdesc}{sample}{population, k}
+ Return a \var{k} length list of unique elements chosen from the
+ population sequence. Used for random sampling without replacement.
+
+ Returns a new list containing elements from the population. The
+ list itself is in random order so that all sub-slices are also
+ random samples. The original sequence is left undisturbed.
+
+ If the population has repeated elements, then each occurence is a
+ possible selection in the sample.
+
+ If indices are needed for a large population, use \function{xrange}
+ as an argument: \code{sample(xrange(10000000), 60)}.
+
+ Optional argument random is a 0-argument function returning a random
+ float in [0.0, 1.0); by default, the standard random.random.
+ \versionadded{2.3}
+ \end{funcdesc}
+
The following functions generate specific real-valued distributions.