On Thu, Sep 18, 2008 at 16:55, Paul Moore <[EMAIL PROTECTED]> 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 > > 1. Integers between 1 and M (simulating M rolls of an N-sided die), or > 2. A sample of N numbers between 1 and M without repeats (simulating > deals of N cards from an M-card deck). > > Example (1) is easy, numpy.random.random_integers(1, M, (SAMPLESIZE, N)) > > But I can't find an obvious equivalent for (2). Am I missing something > glaringly obvious? I'm using numpy - is there maybe something in scipy I > should be looking at?
numpy.array([(numpy.random.permutation(M) + 1)[:N] for i in range(SAMPLESIZE)]) -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman/listinfo/numpy-discussion