Steven D'Aprano wrote:
On Wed, 18 Jul 2007 19:32:35 +, George Sakkis wrote:
...
Wow, can you make a coffee in.. 57ms ?
[snip demonstration of xrange raising an exception]
Of course! Can't you?
And if I use a microwave oven,
[*** deleted section outlining Guido's time machine
On 2007-07-19, Steven D'Aprano [EMAIL PROTECTED] wrote:
On Wed, 18 Jul 2007 19:32:35 +, George Sakkis wrote:
On Jul 16, 10:51 pm, Steven D'Aprano
[EMAIL PROTECTED] wrote:
On Mon, 16 Jul 2007 16:55:53 +0200, Hrvoje Niksic wrote:
2**19937 being a really huge number, it's impossible to
On Jul 16, 10:51 pm, Steven D'Aprano
[EMAIL PROTECTED] wrote:
On Mon, 16 Jul 2007 16:55:53 +0200, Hrvoje Niksic wrote:
2**19937 being a really huge number, it's impossible to exhaust the
Mersenne twister by running it in sequence.
Impossible?
Surely this will do it:
for n in
On Wed, 18 Jul 2007 19:32:35 +, George Sakkis wrote:
On Jul 16, 10:51 pm, Steven D'Aprano
[EMAIL PROTECTED] wrote:
On Mon, 16 Jul 2007 16:55:53 +0200, Hrvoje Niksic wrote:
2**19937 being a really huge number, it's impossible to exhaust the
Mersenne twister by running it in sequence.
On Jul 16, 8:29 pm, Steve Holden [EMAIL PROTECTED] wrote:
Hrvoje Niksic wrote:
Steve Holden [EMAIL PROTECTED] writes:
So it would appear that the developers chose the Knuth algorithm
(with a slight variation) for *their* implementation. Now you have
to ask yourself whether your surmise
Ah, thanks I get it now!
--Shabda
On Jul 17, 7:52 am, Steven D'Aprano
[EMAIL PROTECTED] wrote:
On Mon, 16 Jul 2007 14:45:48 +,shabdaraaj wrote:
On Jul 16, 5:53 pm, Steve Holden [EMAIL PROTECTED] wrote:
shabdaraaj wrote:
I was going through the docs for module-random
Steven D'Aprano [EMAIL PROTECTED] writes:
In the case of CPython, the current implementation uses the Mersenne
Twister, which has a huge period of 2**19937. However, 2081! is
larger than that number, which means that at best a list of 2081
items or longer can't be perfectly shuffled (not
shabda raaj wrote:
The code for shuffle is
if random is None:
random = self.random
for i in reversed(xrange(1, len(x))):
# pick an element in x[:i+1] with which to exchange x[i]
j = int(random() * (i+1))
x[i], x[j] =
Josiah Carlson wrote:
shabda raaj wrote:
[...]
Anyway, is there some test harness we can run to test the robustness
of shuffle? We can run that test harness for large values and see at
what point all permutations are not possible or come with unequal
probability.
Shuffle works as
I was going through the docs for
module-randomhttp://docs.python.org/lib/module-random.html
And I came through this,
*shuffle*( x[, random])
Shuffle the sequence x in place. The optional argument random is a
0-argument function returning a random float in [0.0, 1.0); by default, this
is the
shabda raaj wrote:
I was going through the docs for module-random
http://docs.python.org/lib/module-random.html And I came through this,
* shuffle*( x[, random])
Shuffle the sequence x in place. The optional argument random is a
0-argument function returning a random float
On Jul 16, 5:53 pm, Steve Holden [EMAIL PROTECTED] wrote:
shabda raaj wrote:
I was going through the docs for module-random
http://docs.python.org/lib/module-random.html And I came through this,
* shuffle*(x[, random])
Shuffle the sequence x in place. The optional argument
Steve Holden [EMAIL PROTECTED] writes:
So it would appear that the developers chose the Knuth algorithm
(with a slight variation) for *their* implementation. Now you have
to ask yourself whether your surmise is genuinely correct (in which
case the documentation may contain a bug) or whether
Hrvoje Niksic wrote:
Steve Holden [EMAIL PROTECTED] writes:
So it would appear that the developers chose the Knuth algorithm
(with a slight variation) for *their* implementation. Now you have
to ask yourself whether your surmise is genuinely correct (in which
case the documentation may
shabda raaj wrote:
... Oh, I wasn't aware that I could see the source of all python modules
Well, actually not _all_ (or is that __all__), but that is exactly why
so many of us love Python -- no magic (or at least as little as needed).
--Scott David Daniels
[EMAIL PROTECTED]
--
On Mon, 16 Jul 2007 16:55:53 +0200, Hrvoje Niksic wrote:
2**19937 being a really huge number, it's impossible to exhaust the
Mersenne twister by running it in sequence.
Impossible?
Surely this will do it:
for n in xrange(2**19937 + 1):
random.random()
Admittedly, if each call to
On Mon, 16 Jul 2007 14:45:48 +, shabda raaj wrote:
On Jul 16, 5:53 pm, Steve Holden [EMAIL PROTECTED] wrote:
shabda raaj wrote:
I was going through the docs for module-random
http://docs.python.org/lib/module-random.html And I came through
this,
* shuffle*(x[, random])
2**19937 being a really huge number, it's impossible to exhaust the
Mersenne twister by running it in sequence.
Impossible?
Unfeasible.
Regards,
Martin
--
http://mail.python.org/mailman/listinfo/python-list
18 matches
Mail list logo