Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-16 Thread michael rice
I seem to still be missing some things. I found mt19937 in GSL.Random.Gen, but there are two evalMCs, one in Control.Monad.MC and another in Control.Monad.MC.GSL. Which? Michael - Registering monte-carlo-0.4.1...Installing library in

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-16 Thread Felipe Almeida Lessa
On Thu, Jun 16, 2011 at 3:04 PM, michael rice nowg...@yahoo.com wrote: I seem to still be missing some things. I found mt19937 in GSL.Random.Gen, but there are two evalMCs, one in Control.Monad.MC and another in Control.Monad.MC.GSL. Which? Both are actually the same, because

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-14 Thread Jonas Almström Duregård
Shuffle [1..20], then take 5? Yes, so simple, I'm embarrassed I didn't think of it. That works well for small numbers, but I'm guessing it will evaluate the entire list so it should not be used for large inputs. If you have a large interval and use a relatively small part of it, the following

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-14 Thread michael rice
I had the same thought, since my interval [1..1] is rather large. Thanks, MIchael --- On Tue, 6/14/11, Jonas Almström Duregård jonas.dureg...@chalmers.se wrote: From: Jonas Almström Duregård jonas.dureg...@chalmers.se Subject: Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-14 Thread Patrick Perry
There are time/space tradeoffs in sampling without replacement. The version in monte-carlo takes space O(n) and time O(k), for all k. I chose this algorithm instead of a streaming algorithm, with takes space O(k) and time O(n). If k is much less than n, you can improve a bit. Here is a

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-14 Thread Patrick Perry
Correction: the version in monte-carlo takes time O(n), but it only consumes k random numbers. The streaming algorithm consumes n random numbers. On Jun 14, 2011, at 12:04 PM, Patrick Perry wrote: There are time/space tradeoffs in sampling without replacement. The version in monte-carlo

[Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
Is there an (existing) way to select 5 Ints randomly (no duplicates) from a population, say 1-20 (inclusive)? Michael___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Alexander Solla
On Mon, Jun 13, 2011 at 4:56 PM, michael rice nowg...@yahoo.com wrote: Is there an (existing) way to select 5 Ints randomly (no duplicates) from a population, say 1-20 (inclusive)? Michael This is as close as I have gotten, but it is only probabilistically true.

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Arlen Christian Mart Cuss
On Mon, 2011-06-13 at 16:56 -0700, michael rice wrote: Is there an (existing) way to select 5 Ints randomly (no duplicates) from a population, say 1-20 (inclusive)? Does anything from random-extras look like it'll work?

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Felipe Almeida Lessa
On Mon, Jun 13, 2011 at 8:56 PM, michael rice nowg...@yahoo.com wrote: Is there an (existing) way to select 5 Ints randomly (no duplicates) from a population, say 1-20 (inclusive)? Yes, already implemented in the monte-carlo package as sampleSubset [1], sampleSubset :: MonadMC m = [a] - Int

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
Thanks, all. It seemed like something like this should exist in a prob/stat package, and if so, didn't want to reinvent the wheel. Shuffle [1..20], then take 5? Yes, so simple, I'm embarrassed I didn't think of it. Michael --- On Mon, 6/13/11, Felipe Almeida Lessa felipe.le...@gmail.com wrote:

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
Reason why this doesn't work? Michael == [michael@sabal ~]$ cabal install monte-carloResolving dependencies...Downloading primitive-0.3.1...Configuring primitive-0.3.1...Preprocessing library primitive-0.3.1...Building primitive-0.3.1...[1 of 7] Compiling Data.Primitive.MachDeps (

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread Felipe Almeida Lessa
On Mon, Jun 13, 2011 at 11:44 PM, michael rice nowg...@yahoo.com wrote: Downloading gsl-random-0.4.3... [1 of 1] Compiling Main             ( /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/Setup.lhs, /tmp/gsl-random-0.4.32479/gsl-random-0.4.3/dist/setup/Main.o ) Linking

Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints

2011-06-13 Thread michael rice
And then reinstall the monte-carlo? Michael --- On Mon, 6/13/11, Felipe Almeida Lessa felipe.le...@gmail.com wrote: From: Felipe Almeida Lessa felipe.le...@gmail.com Subject: Re: [Haskell-cafe] Acquiring a random set of a specific size (w/o dups) from a range of Ints To: michael rice