[Numpy-discussion] Generating random samples without repeats

Pierre GM pgmdevlist@gmail....
Fri Sep 19 04:17:05 CDT 2008


On Friday 19 September 2008 05:08:20 Paul Moore wrote:
> Robert Kern <robert.kern <at> gmail.com> writes:
> > On Thu, Sep 18, 2008 at 16:55, Paul Moore <pf_moore <at> yahoo.co.uk> 
wrote:
> > > I want to generate a series of random samples, to do simulations based
> > > on them. Essentially, I want to be able to produce a SAMPLESIZE * N
> > > matrix, where each row of N values consists of either

> > > 2. A sample of N numbers between 1 and M without repeats (simulating
> > >    deals of N cards from an M-card deck).

Have you considered numpy.random.shuffle ?

a = np.arange(1, M+1)
result = np.random.shuffle(a)[:N]





More information about the Numpy-discussion mailing list