[Numpy-discussion] sample without replacement

josef.pktd@gmai... josef.pktd@gmai...
Mon Dec 20 20:41:16 CST 2010


On Mon, Dec 20, 2010 at 11:28 AM, Alan G Isaac <alan.isaac@gmail.com> wrote:
> I want to sample *without* replacement from a vector
> (as with Python's random.sample).  I don't see a direct
> replacement for this, and I don't want to carry two
> PRNG's around.  Is the best way something like  this?
>
>        permutation(myvector)[:samplesize]

python has it in random

sample( population, k)
Return a k length list of unique elements chosen from the population
sequence. Used for random sampling without replacement. New in version
2.3

Josef


>
> Thanks,
> Alan Isaac
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>


More information about the NumPy-Discussion mailing list