This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author xksteven
Recipients Christian.Kleineidam, NeilGirdhar, aisaac, dkorchem, madison.may, mark.dickinson, pitrou, rhettinger, serhiy.storchaka, tim.peters, westley.martinez, xksteven
Date 2016-04-06.22:46:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1459982762.74.0.883345216767.issue18844@psf.upfronthosting.co.za>
In-reply-to
Content
Okay so I added a few lines of code.  One to make it return a single number if amount == 1 and the other to check that the amount > 1.

The main difference I've noticed between this implementation and previous versions compared to say R is that in R they provide a boolean flag to ask if sampling with replacement.

Here's there documentation and source code:
https://github.com/wch/r-source/blob/e5b21d0397c607883ff25cca379687b86933d730/src/library/base/man/sample.Rd

https://github.com/wch/r-source/blob/e5b21d0397c607883ff25cca379687b86933d730/src/library/base/R/sample.R

Maybe someone else can comment more on the use cases.  I can only say for myself that I've needed this function plenty of times when working with samples that have a non uniform distribution.
History
Date User Action Args
2016-04-06 22:46:02xkstevensetrecipients: + xksteven, tim.peters, rhettinger, mark.dickinson, pitrou, aisaac, westley.martinez, serhiy.storchaka, NeilGirdhar, madison.may, dkorchem, Christian.Kleineidam
2016-04-06 22:46:02xkstevensetmessageid: <1459982762.74.0.883345216767.issue18844@psf.upfronthosting.co.za>
2016-04-06 22:46:02xkstevenlinkissue18844 messages
2016-04-06 22:46:02xkstevencreate