Re: random changes

Discussion in 'Python' started by Raymond Hettinger, Aug 8, 2003.

  1. "dan" <> wrote in message
    news:...
    > just a suggestion --
    >
    > next time the core RNG is changed, I think it would be useful to have
    > an
    > -oldrandom switch. It is common practice in simulation projects to
    > depend
    > on the fact that your random numbers will come out the same if you use
    > the same seed. In bumping to 2.3 with the new Mersenne algorithm, I
    > have no easy way of duplicating my old results.



    It would have been helpful to included a sample call, the results, and
    the version of Python you were using. It looks like you were using
    Py2.0 and upgraded to Py2.3. This difference you are seeing came
    version Py2.1 when WichmannHill's seed method was improved
    (the upgrade to the Mersenne Twister has nothing to do with it):

    """
    random.py's seed() function is new. For bit-for-bit compatibility with
    prior releases, use the whseed function instead. The new seed function
    addresses two problems: (1) The old function couldn't produce more than
    about 2**24 distinct internal states; the new one about 2**45 (the best
    that can be done in the Wichmann-Hill generator). (2) The old function
    sometimes produced identical internal states when passed distinct
    integers, and there was no simple way to predict when that would happen;
    the new one guarantees to produce distinct internal states for all
    arguments in [0, 27814431486576L).
    """

    So, to get your old results with Py2.3, try something like:

    import random
    rng = random.WichmannHill()
    rng.whseed(12345)
    for i in range(6):
    print rng.randint(1, 10)


    Raymond Hettinger
     
    Raymond Hettinger, Aug 8, 2003
    #1
    1. Advertising

  2. Raymond Hettinger

    dan Guest

    "Raymond Hettinger" <> wrote in message news:<S_PYa.73$>...

    > So, to get your old results with Py2.3, try something like:
    >
    > import random
    > rng = random.WichmannHill()
    > rng.whseed(12345)
    > for i in range(6):
    > print rng.randint(1, 10)
    >

    that worked, thanks
     
    dan, Aug 10, 2003
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Darren Clark

    Random NOt random?

    Darren Clark, Jun 24, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    469
    mikeb
    Jun 24, 2004
  2. Maziar Aflatoun

    Random not really random...

    Maziar Aflatoun, Aug 4, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    26,751
    Maziar Aflatoun
    Aug 5, 2004
  3. Andrew Dalke

    Re: random changes

    Andrew Dalke, Aug 7, 2003, in forum: Python
    Replies:
    2
    Views:
    295
    Andrew Dalke
    Aug 8, 2003
  4. globalrev
    Replies:
    4
    Views:
    782
    Gabriel Genellina
    Apr 20, 2008
  5. VK
    Replies:
    15
    Views:
    1,218
    Dr J R Stockton
    May 2, 2010
Loading...

Share This Page