Open a9bc4e33-7b98-4180-affc-8dfcef89e22b opened 12 years ago
From the documentation of sage.misc.randstate
:
Note that wrappers of all the random number generation methods from
Python's :mod:`random` module are available at the Sage command
line, and these wrappers are properly affected by :meth:`set_random_seed`. ::
Indeed,
sage: set_random_seed(0); randint(0,20)
2
sage: set_random_seed(0); randint(0,20)
2
sage: set_random_seed(0); randint(0,20)
2
sage: type(randint(0,20))
<type 'int'>
So, Witty's design was to wrap python's random functionality to get it to respect set_random_seed rather than reach into python and change the seed there. Perhaps he had thread-safety in mind or something like that?
With that design, the behaviour noted in this ticket is not a bug but a feature that arises from circumventing the advertised API.
This ticket can still be considered as a request: can we reconsider the design decisions made in randomstate
, of course.
Certainly not critical. Not a defect either.
William Stein reported on sage.devel:http://groups.google.com/group/sage-devel/browse_thread/thread/5fa8e919dd83b4b7:
William said "Basically, I expected that Sage's "set_random_seed" would actually set Python's own random seed, given that it sets gp, gap, maxima, etc."
Component: misc
Issue created by migration from https://trac.sagemath.org/ticket/12580