generating random numbers, vectors, etc. and random seed
Publié : mar. déc. 19, 2017 12:52 pm
Hi,
How do you set the seed of the random number generator for giac. I want to specifically used ranm and rand but I get the impression that I am using randseed wrongly.
Edit: I realized that there is a bug in python that does not appear in Xcas.
In Xcas, randseed and srand both will return the seed that I give. But in python this is not happening and so I get a different random number even if I have the same seed set. Here is what I get in python:
Here is what happens in XCas:
How do you set the seed of the random number generator for giac. I want to specifically used ranm and rand but I get the impression that I am using randseed wrongly.
Code : Tout sélectionner
from giacpy import randseed
randseed(123)
In Xcas, randseed and srand both will return the seed that I give. But in python this is not happening and so I get a different random number even if I have the same seed set. Here is what I get in python:
Code : Tout sélectionner
>>> from giacpy import rand, randseed
>>> randseed(12)
1648307537
>>> rand(111)
67
>>> randseed(12)
615922008
>>> rand(111)
41
Code : Tout sélectionner
randseed(12)
12
rand(111)
88
randseed(12)
12
rand(111)
88
rand(111)
51