Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread alex23
On 11/11/2013 11:19 AM, Robert Kern wrote: On 2013-11-11 00:49, alex23 wrote: The random module uses os.urandom, No, it doesn't. random.random() is an alias to the random() method on the random.Random class, which uses the Mersenne Twister to generate values. os.urandom() gets called i

Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Mark Lawrence
On 11/11/2013 01:15, Ned Batchelder wrote: On Friday, November 8, 2013 12:48:04 PM UTC-5, Pascal Bit wrote: Here's the code: from random import random from time import clock s = clock() for i in (1, 2, 3, 6, 8): M = 0 N = 10**i for n in xrange(N): r = random()

Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Ned Batchelder
On Friday, November 8, 2013 12:48:04 PM UTC-5, Pascal Bit wrote: > Here's the code: > > from random import random > from time import clock > > s = clock() > > for i in (1, 2, 3, 6, 8): > M = 0 > N = 10**i > > for n in xrange(N): > r = random() > if 0.5 < r < 0.6

Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread Robert Kern
elf... The python version in this case is 1.5 times faster... I don't understand. What causes this? The random module uses os.urandom, No, it doesn't. random.random() is an alias to the random() method on the random.Random class, which uses the Mersenne Twister to generate values

Re: Code with random module faster on the vm than the vm host...

2013-11-10 Thread alex23
is 1.5 times faster... I don't understand. What causes this? The random module uses os.urandom, which relies on OS implementations of randomness functionality: "On a UNIX-like system this will query /dev/urandom, and on Windows it will use CryptGenRandom()." http://docs.py

Code with random module faster on the vm than the vm host...

2013-11-08 Thread Pascal Bit
Here's the code: from random import random from time import clock s = clock() for i in (1, 2, 3, 6, 8): M = 0 N = 10**i for n in xrange(N): r = random() if 0.5 < r < 0.6: M += 1 k = (N, float(M)/N) print (clock()-s) Running on win7 python 2.7 32 b

Re: difference between random module in python 2.6 and 3.2?

2012-02-07 Thread Ulrich Eckhardt
. 2. hack the random module into something nonrandom I think you can "import debug_random as random" and then have your testee automatically pick up that module instead of the real one. Since you already hardcoded the results to check against ("expected = ..." in your code

Re: difference between random module in python 2.6 and 3.2?

2012-02-07 Thread Serhiy Storchaka
07.02.12 00:06, Matej Cepl написав(ла): > return seq[int(random.random() * len(seq))] > > doesn't seem like something so terrible (and maintenance intense). :) _choice('abc') returns 'a' with probability P('a') = 1501199875790165/4503599627370496 = 1/3 - 1/13510798882111488 and 'b' with probabi

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
I really don't care that much about distribution of my choice, this function def _choice(self, seq): """Choose a random element from a non-empty sequence. Embedding random.choice from 2.6 in order to get an uniform results between 2.6 and 3.2, wher

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Tim Chase
On 02/06/12 12:48, Aaron France wrote: On 02/06/2012 09:57 AM, Matej Cepl wrote: Silly, of course, the solution is obvious ... I have just embedded random.choice from 2.6 to my code. Matěj Is the above actually a good idea though? What I understand you're doing is embedding the source from th

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Aaron France
On 02/06/2012 09:57 AM, Matej Cepl wrote: On 6.2.2012 09:45, Matej Cepl wrote: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Mel Wilson
Steven D'Aprano wrote: > A more explicit note will help, but the basic problem applies: how do you > write deterministic tests given that the random.methods (apart from > random.random itself) can be changed without warning? Biting the bullet would mean supplying your own PRNG, under your control

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
On 6.2.2012 09:45, Matej Cepl wrote: Also, how could I write a re-implementation of random.choice which would work same on python 2.6 and python 3.2? It is not only matter of unit tests, but I would really welcome if the results on both versions produce the same results. Silly, of course, the s

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Matej Cepl
On 6.2.2012 09:05, Steven D'Aprano wrote: You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations can be changed if improve

Re: difference between random module in python 2.6 and 3.2?

2012-02-06 Thread Steven D'Aprano
rwise improving them. This statement is not limited to the > random module. > > You have persuaded me that the doc should be more explicit that while > the basic random.random sequence will be kept repeatable with seed set > (except perhaps after a changeover of several releases),

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy
ving them. This statement is not limited to the random module. You have persuaded me that the doc should be more explicit that while the basic random.random sequence will be kept repeatable with seed set (except perhaps after a changeover of several releases), the convenience transformations ca

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 00:07:04 -0500, Terry Reedy wrote: > On 2/5/2012 11:01 PM, Steven D'Aprano wrote: > >> Reading the docs, I would expect that when using an int as seed, you >> should get identical results. > > That is similar to expecting hash to be consistent from version to > version. No.

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Terry Reedy
an empty sequence') return seq[i] The change was announced in What's New in 3.2 random The integer methods in the random module now do a better job of producing uniform distributions. Previously, they computed selections with int(n*random()) which had a slight bias whenever n was no

Re: difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Steven D'Aprano
On Mon, 06 Feb 2012 02:27:38 +0100, Matej Cepl wrote: > Strange thing is that this unit tests correctly with python3, but fails > with python2. The problem is that apparently python3 random.choice picks > different element of self[k] than the one python2 (at least, both of > them are constant in t

difference between random module in python 2.6 and 3.2?

2012-02-05 Thread Matej Cepl
Hi, I have this working function: def as_xml(self): out = etree.Element("or") for k in sorted(self.keys()): out.append(etree.Element("hostname", attrib={'op': '=', 'value': random.choice(self[k])})) # ... return somehow string representing

RE: Random module missing?

2009-09-23 Thread Brown, Rodrick
: Random module missing? On Wed, Sep 23, 2009 at 5:00 PM, Brown, Rodrick wrote: > I seen some documentation about random.random() but my version seems to be > broken? > > Python 2.3.4 (#1, Jul 16 2009, 07:03:37) [GCC 3.4.6 20060404 (Red Hat > 3.4.6-11)] on linux2 Type "help&quo

Re: Random module missing?

2009-09-23 Thread Robert Kern
On 2009-09-23 16:00 PM, Brown, Rodrick wrote: I seen some documentation about random.random() but my version seems to be broken? Python 2.3.4 (#1, Jul 16 2009, 07:03:37) [GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. imp

Re: Random module missing?

2009-09-23 Thread Jerry Hill
On Wed, Sep 23, 2009 at 5:00 PM, Brown, Rodrick wrote: > I seen some documentation about random.random() but my version seems to be > broken? > > Python 2.3.4 (#1, Jul 16 2009, 07:03:37) > [GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2 > Type "help", "copyright", "credits" or "license" for mor

Random module missing?

2009-09-23 Thread Brown, Rodrick
I seen some documentation about random.random() but my version seems to be broken? Python 2.3.4 (#1, Jul 16 2009, 07:03:37) [GCC 3.4.6 20060404 (Red Hat 3.4.6-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import random >>> dir(random) ['__builtins__', '

Re: Simple addition to random module - Student's t

2009-09-03 Thread Daniel Stutzbach
On Wed, Sep 2, 2009 at 2:15 PM, Raymond Hettinger wrote: > ISTM, there ought to be a statistics module that can calculate > cumulative distribution functions for a variety of distributions. > This would be far more helpful than creating more generators. > Many of the formulas for cumulative dist

Re: Simple addition to random module - Student's t

2009-09-03 Thread Terry Reedy
Robert Kern wrote: On 2009-09-02 14:15 PM, Raymond Hettinger wrote: On Sep 2, 6:51 am, Thomas Philips wrote: While the random module allows one to generate randome numbers with a variety of distributions, some useful distributions are omitted - the Student's t being among them. I'

Re: Simple addition to random module - Student's t

2009-09-02 Thread Robert Kern
On 2009-09-02 14:15 PM, Raymond Hettinger wrote: On Sep 2, 6:51 am, Thomas Philips wrote: While the random module allows one to generate randome numbers with a variety of distributions, some useful distributions are omitted - the Student's t being among them. I'm curious to hear

Re: Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
On Sep 2, 2:37 pm, Mark Dickinson wrote: > On Sep 2, 6:15 pm, Thomas Philips wrote: > > > I mis-spoke - the variance is infinite when df=2 (the variance is df/ > > (df-2), > > Yes:  the variance is infinite both for df=2 and df=1, and Student's t > with df=1 doesn't even have an expectation.  I d

Re: Simple addition to random module - Student's t

2009-09-02 Thread Raymond Hettinger
> To get this into core Python, you'd usually submit a feature request > athttp://bugs.python.org. If you do submit a patch, please assign it to me. I've been the primary maintainer for that module for several years. Raymond Hettinger -- http://mail.python.org/mailman/listinfo/python-list

Re: Simple addition to random module - Student's t

2009-09-02 Thread Raymond Hettinger
On Sep 2, 6:51 am, Thomas Philips wrote: > While the random module allows one to generate randome numbers with a > variety of distributions, some useful distributions are omitted - the > Student's t being among them. I'm curious to hear what your use cases are. My unde

Re: Simple addition to random module - Student's t

2009-09-02 Thread Mark Dickinson
On Sep 2, 6:15 pm, Thomas Philips wrote: > I mis-spoke - the variance is infinite when df=2 (the variance is df/ > (df-2), Yes: the variance is infinite both for df=2 and df=1, and Student's t with df=1 doesn't even have an expectation. I don't see why this would stop you from generating meanin

Re: Simple addition to random module - Student's t

2009-09-02 Thread Robert Kern
On 2009-09-02 11:28 AM, Mark Dickinson wrote: On Sep 2, 2:51 pm, Thomas Philips wrote: def student_t(df): # df is the number of degrees of freedom if df< 2 or int(df) != df: raise ValueError, 'student_tvariate: df must be a integer> 1' By the way, why do you exclude th

Re: Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
On Sep 2, 1:03 pm, Thomas Philips wrote: > On Sep 2, 12:28 pm, Mark Dickinson wrote: > > > On Sep 2, 2:51 pm, Thomas Philips wrote: > > > > def student_t(df):         # df is the number of degrees of freedom > > >     if df < 2  or int(df) != df: > > >        raise ValueError, 'student_tvariate:

Re: Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
On Sep 2, 12:28 pm, Mark Dickinson wrote: > On Sep 2, 2:51 pm, Thomas Philips wrote: > > > def student_t(df):         # df is the number of degrees of freedom > >     if df < 2  or int(df) != df: > >        raise ValueError, 'student_tvariate: df must be a integer > 1' > > By the way, why do you

Re: Simple addition to random module - Student's t

2009-09-02 Thread Mark Dickinson
On Sep 2, 2:51 pm, Thomas Philips wrote: > def student_t(df):         # df is the number of degrees of freedom >     if df < 2  or int(df) != df: >        raise ValueError, 'student_tvariate: df must be a integer > 1' By the way, why do you exclude the possibility df=1 here? -- Mark -- http://m

Re: Simple addition to random module - Student's t

2009-09-02 Thread Mark Dickinson
On Sep 2, 2:51 pm, Thomas Philips wrote: > While the random module allows one to generate randome numbers with a > variety of distributions, some useful distributions are omitted - the > Student's t being among them. This distribution is easily derived from > the normal distrib

Simple addition to random module - Student's t

2009-09-02 Thread Thomas Philips
While the random module allows one to generate randome numbers with a variety of distributions, some useful distributions are omitted - the Student's t being among them. This distribution is easily derived from the normal distribution and the chi-squared distribution (which in turn is a sp

Re: random module gives same results across all configurations?

2009-03-04 Thread Carl Banks
On Mar 4, 12:33 am, "Diez B. Roggisch" wrote: > > So far I get the same results under Mac OS X, Windows, and Linux > > (Google App Engine).  I'm particularly interested in getting the same > > results under the Google App Engine even as Google upgrades its > > servers over time. > > I just had a l

Re: random module gives same results across all configurations?

2009-03-04 Thread Diez B. Roggisch
Paul Rubin schrieb: "Diez B. Roggisch" writes: Random uses AFAIK rand/srand from the stdlib.h of your platform (*nix, no idea how that beast is called in redmond). According to http://docs.python.org/library/random.html it uses Mersenne Twister. Yeah, I figured that out later, sorry for th

Re: random module gives same results across all configurations?

2009-03-04 Thread Paul Rubin
"Diez B. Roggisch" writes: > Random uses AFAIK rand/srand from the stdlib.h of your platform (*nix, > no idea how that beast is called in redmond). According to http://docs.python.org/library/random.html it uses Mersenne Twister. -- http://mail.python.org/mailman/listinfo/python-list

Re: random module gives same results across all configurations?

2009-03-04 Thread Diez B. Roggisch
So far I get the same results under Mac OS X, Windows, and Linux (Google App Engine). I'm particularly interested in getting the same results under the Google App Engine even as Google upgrades its servers over time. I just had a look into the python source - and I was wrong, it appears rando

Re: random module gives same results across all configurations?

2009-03-03 Thread Amir Michail
On Mar 4, 2:26 am, "Diez B. Roggisch" wrote: > Amir Michail schrieb: > > > On Mar 3, 10:05 pm, Chris Rebert wrote: > >> On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: > >>> Hi, > >>> Is it the case that the random module will always gi

Re: random module gives same results across all configurations?

2009-03-03 Thread Diez B. Roggisch
Amir Michail schrieb: On Mar 3, 10:05 pm, Chris Rebert wrote: On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: Hi, Is it the case that the random module will always give the same results if given the same seed across all configurations (e.g., architectures, compilers, etc.)? Your

Re: random module gives same results across all configurations?

2009-03-03 Thread Carl Banks
On Mar 3, 6:59 pm, Amir Michail wrote: > Hi, > > Is it the case that the random module will always give the same > results if given the same seed across all configurations (e.g., > architectures, compilers, etc.)? If you need a repeatable sequence, such as for unit testing, y

Re: random module gives same results across all configurations?

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 7:11 PM, Amir Michail wrote: > On Mar 3, 10:05 pm, Chris Rebert wrote: >> On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: >> > Hi, >> >> > Is it the case that the random module will always give the same >> > results if giv

Re: random module gives same results across all configurations?

2009-03-03 Thread Amir Michail
On Mar 3, 10:05 pm, Chris Rebert wrote: > On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: > > Hi, > > > Is it the case that the random module will always give the same > > results if given the same seed across all configurations (e.g., > > architectures, compi

Re: random module gives same results across all configurations?

2009-03-03 Thread Chris Rebert
On Tue, Mar 3, 2009 at 6:59 PM, Amir Michail wrote: > Hi, > > Is it the case that the random module will always give the same > results if given the same seed across all configurations (e.g., > architectures, compilers, etc.)? Your question is vague. Define what you mean by &q

random module gives same results across all configurations?

2009-03-03 Thread Amir Michail
Hi, Is it the case that the random module will always give the same results if given the same seed across all configurations (e.g., architectures, compilers, etc.)? Amir -- http://mail.python.org/mailman/listinfo/python-list

Re: Using the Random Module.

2008-07-12 Thread WDC
On Jul 12, 10:06 am, Steven D'Aprano <[EMAIL PROTECTED] cybersource.com.au> wrote: > On Fri, 11 Jul 2008 12:27:32 -0700, castironpi wrote: > > You want a random integer.  Is there a range you want it in? > > > Past a certain point, you'll exceed the granularity of the random number > > generator, a

Re: Using the Random Module.

2008-07-12 Thread Steven D'Aprano
On Fri, 11 Jul 2008 12:27:32 -0700, castironpi wrote: > You want a random integer. Is there a range you want it in? > > Past a certain point, you'll exceed the granularity of the random number > generator, and some values in the range will never be generated. You might want to produce an unboun

Re: Using the Random Module.

2008-07-11 Thread Dan Stromberg
On Fri, 11 Jul 2008 12:27:32 -0700, castironpi wrote: > On Jul 11, 1:29 pm, WDC <[EMAIL PROTECTED]> wrote: >> On Jul 11, 2:15 pm, Michiel Overtoom <[EMAIL PROTECTED]> wrote: >> >> > You wrote... >> > >Is there a better way to do that besides doing this: >> >> > random.randint(0

Re: Using the Random Module.

2008-07-11 Thread castironpi
On Jul 11, 1:29 pm, WDC <[EMAIL PROTECTED]> wrote: > On Jul 11, 2:15 pm, Michiel Overtoom <[EMAIL PROTECTED]> wrote: > > > You wrote... > > >Is there a better way to do that besides doing this: > > > random.randint(0, 9) > > >09657398671238769 > > > Maybe this? >

Re: Using the Random Module.

2008-07-11 Thread WDC
On Jul 11, 2:15 pm, Michiel Overtoom <[EMAIL PROTECTED]> wrote: > You wrote... > >Is there a better way to do that besides doing this: > > random.randint(0, 9) > >09657398671238769 > > Maybe this? > >         random.randint(0, 9e16) > > -- > "The ability of the O

Re: Using the Random Module.

2008-07-11 Thread Michiel Overtoom
You wrote... >Is there a better way to do that besides doing this: > random.randint(0, 9) >09657398671238769 Maybe this? random.randint(0, 9e16) -- "The ability of the OSS process to collect and harness the collective IQ of thousands of individuals

Using the Random Module.

2008-07-11 Thread WDC
I am currently learning, and loving, Python and have a question about random(). Right now, what I have to do to get a whole number and not a decimal using random.random() is this: >>>random.random() 0.84765728501856734 >>>_ * 10**17 84765728501856734.0 Is there a better way to do that besides do

Re: Error in random module, bad installation?

2007-09-13 Thread Andrew F
On Sep 13, 12:57 am, Tim Roberts <[EMAIL PROTECTED]> wrote: > Andrew F <[EMAIL PROTECTED]> wrote: > >I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the > >location of a number of libraries and tools. > > >So far I've tracked most errors, but this one has me scratching my > >head :

Re: Error in random module, bad installation?

2007-09-12 Thread Tim Roberts
Andrew F <[EMAIL PROTECTED]> wrote: >I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the >location of a number of libraries and tools. > >So far I've tracked most errors, but this one has me scratching my >head : > >$ which python >/usr/local/bin/python >$ echo $PYTHONPATH >/usr/l

Re: Error in random module, bad installation?

2007-09-12 Thread Carsten Haese
object is not callable You have a file called random.py in your current directory. It's shadowing the random module from the library. HTH, -- Carsten Haese http://informixdb.sourceforge.net -- http://mail.python.org/mailman/listinfo/python-list

Error in random module, bad installation?

2007-09-12 Thread Andrew F
I'm a linux user and I just upgraded from 2.1 to 2.5 and changed the location of a number of libraries and tools. So far I've tracked most errors, but this one has me scratching my head : $ which python /usr/local/bin/python $ echo $PYTHONPATH /usr/local/bin/python $ python Python 2.5.1 (r251:548

Re: random module

2006-10-29 Thread Fredrik Lundh
Moishy Gluck wrote: > I am using the random module to generate a session tracker. I use this > code to generate a random number "random.random() * 1" > The session is stored in a mysql database under the field session_id. > The problem is when I try to su

random module

2006-10-28 Thread Moishy Gluck
HiI am using the random module to generate a session tracker. I use this code to generate a random number "random.random() * 1" The session is stored in a mysql database under the field session_id. The problem is when I try to submit the random number into my database

Re: import random module

2006-03-23 Thread Just
In article <[EMAIL PROTECTED]>, "Carl Banks" <[EMAIL PROTECTED]> wrote: > Ben Finney wrote: > > "DataSmash" <[EMAIL PROTECTED]> writes: > > > * random.py: > > > > > > import random > > > > Now that you've tripped over this ambiguity of Python's current > > 'import' behaviour, you may be intereste

Re: import random module

2006-03-22 Thread Carl Banks
Ben Finney wrote: > "DataSmash" <[EMAIL PROTECTED]> writes: > > * random.py: > > > > import random > > Now that you've tripped over this ambiguity of Python's current > 'import' behaviour, you may be interested to know that the behaviour > will change to solve this: > > http://www.python.org/de

Re: import random module

2006-03-22 Thread Ben Finney
"DataSmash" <[EMAIL PROTECTED]> writes: > * random.py: > > import random Now that you've tripped over this ambiguity of Python's current 'import' behaviour, you may be interested to know that the behaviour will change to solve this: http://www.python.org/dev/peps/pep-0328/> In brief: Python

Re: import random module

2006-03-22 Thread Michael Tobis
Wow. Six simultaneous responses! Python rocks! Anyway, I actually tried it, and persisted through the secondary confusion about the lurking .pyc file, so even though I'm in sixth place I get points for completeness... mt -- http://mail.python.org/mailman/listinfo/python-list

Re: import random module

2006-03-22 Thread Tomas Brabenec
You must rename Your script. Your script doesn't same name as calling module. Tomas Brabenec http://brabenec.net DataSmash napsal(a): > Hi, > When I import the random module at the python interpreter, it works > fine: > >>>> import random >>>&

Re: import random module

2006-03-22 Thread DataSmash
Much Thanks! I deleted the random.pyc and renamed the script and everything is good! R.D. -- http://mail.python.org/mailman/listinfo/python-list

Re: import random module

2006-03-22 Thread DataSmash
Much Thanks! I deleted the random.pyc and renamed the script and everything is good! R.D. -- http://mail.python.org/mailman/listinfo/python-list

Re: import random module

2006-03-22 Thread Richard Brodie
"Benjamin Niemann" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Don't name your script 'random.py' (or any other name from the stdlib). > 'import random' will import the script itself (not the random module from > the stdlib), wh

Re: import random module

2006-03-22 Thread Michael Tobis
1) remove the file random.pyc in your working directory 2) rename the file random.py to something else and run it. The import mechanism is looking for random.pyc or random.py, but you have already named your file that! Your current directory is above your library directory in python's search path

Re: import random module

2006-03-22 Thread Gerard Flanagan
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: > >>> import random > >>> x = random.randint(1,55) > >>> print x > 14 > >>> > > BUT, when I put the same code in a python sc

Re: import random module

2006-03-22 Thread Jorge Godoy
"DataSmash" <[EMAIL PROTECTED]> writes: > Hi, > When I import the random module at the python interpreter, it works > fine: >>>> import random >>>> x = random.randint(1,55) >>>> print x > 14 >>>> > > BUT, w

Re: import random module

2006-03-22 Thread Daniel Dittmar
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: >>>> import random >>>> x = random.randint(1,55) >>>> print x > 14 > > BUT, when I put the same code in a python script: > * random.py: &

Re: import random module

2006-03-22 Thread Benjamin Niemann
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: >>>> import random >>>> x = random.randint(1,55) >>>> print x > 14 >>>> > > BUT, when I put the same code in a python scri

Re: import random module

2006-03-22 Thread Diez B. Roggisch
DataSmash wrote: > Hi, > When I import the random module at the python interpreter, it works > fine: >>>> import random >>>> x = random.randint(1,55) >>>> print x > 14 >>>> > > BUT, when I put the same code in a python script: &g

import random module

2006-03-22 Thread DataSmash
Hi, When I import the random module at the python interpreter, it works fine: >>> import random >>> x = random.randint(1,55) >>> print x 14 >>> BUT, when I put the same code in a python script: * random.py: import random x = random.randint(1,55) print x a

Re: random module question

2005-06-07 Thread Raymond Hettinger
>> Is Mersenne Twister currently available at all in Jython, for example? Googling for "java mersenne twister" provides multiple hits including: http://www.axlradius.com/freestuff/Free.htm#MT Raymond -- http://mail.python.org/mailman/listinfo/python-list

Re: random module question

2005-06-06 Thread Roose
Raymond Hettinger wrote: > The answer is a qualified Yes. While the core generator (currently Thanks! That is the answer I'm looking for. And to Paul Rubin, it is a good point that Jython might not support it, but at this point it doesn't interest me. The program is only for myself anyway.

Re: random module question

2005-06-06 Thread Paul Rubin
"Raymond Hettinger" <[EMAIL PROTECTED]> writes: > >> Can I rely on the random.py module to produce the same series of > >> numbers for future/past versions of Python, given the same seed? > > The answer is a qualified Yes. While the core generator (currently the > Mersenne Twister algorithm) is s

Re: random module question

2005-06-06 Thread Raymond Hettinger
>> Can I rely on the random.py module to produce the same series of >> numbers for future/past versions of Python, given the same seed? The answer is a qualified Yes. While the core generator (currently the Mersenne Twister algorithm) is subject to change across versions, whenever we've updated t

Re: random module question

2005-06-05 Thread Paul Rubin
"Roose" <[EMAIL PROTECTED]> writes: > Can I rely on the random.py module to produce the same series of numbers for > future/past versions of Python, given the same seed? Can I rely on it > across different architectures and operating systems? > > I looked at the docs and couldn't find this stat

random module question

2005-06-05 Thread Roose
Can I rely on the random.py module to produce the same series of numbers for future/past versions of Python, given the same seed? Can I rely on it across different architectures and operating systems? I looked at the docs and couldn't find this stated anywhere. My feeling is yes, but it's a f

Re: Hash of integers for use in Random module

2005-03-06 Thread Will McGugan
Will McGugan wrote: Hi, If I retrieve the hash of an integer, will it always return the same value across platforms? This reason I ask is that I want to produce a sequence of pseudo random numbers using the random module, that I can re-create later on. So I'll need to store the seed value

Hash of integers for use in Random module

2005-03-06 Thread Will McGugan
Hi, If I retrieve the hash of an integer, will it always return the same value across platforms? This reason I ask is that I want to produce a sequence of pseudo random numbers using the random module, that I can re-create later on. So I'll need to store the seed value, but Random.seed ta