python - Discrepancy of the state of `numpy.random` disappears -


there 2 python runs of same project different settings, same random seeds.

the project contains function returns couple of random numbers using numpy.random.uniform.

regardless of other uses of numpy.random in python process, series of function calls in both of runs generate same sequences, until point.

and after generating different results 1 time @ point, generate same sequences again, period.

i haven't tried using numpy.random.randomstate yet, how possible?

is coincidence somewhere uses numpy.random caused discrepancy , fixed again?

i'm curious if possibility or there explanation.

thanks in advance.

add: forgot mention there no seeding @ point.

when use random module in numpy, each randomly generated number (regardless of distribution/function) uses same "global" instance of randomstate. when set seed using numpy.random.seed(), set seed of 'global' instance of randomstate. same principle random library in python.

i'm not sure of specific implementation of numpy random functions, suspect each random function make underlying mersenne twister advance number of 'steps', number of steps not being same between different random functions.

so, if order of every call random function not same between separate runs, may see divergence in generated sequence of random numbers, convergence again if mersenne twister 'steps' line again.

you around initialising separate randomstate instance each function using. example:

import numpy np  seed = 12345 r_uniform = np.random.randomstate(seed) r_randint = np.random.randomstate(seed)  a_random_uniform_number = r_uniform.uniform() a_random_int = r_randint.randint(10) 

you might want set different seeds each instance - depend on using these pseudo-random numbers for.


Comments

Popular posts from this blog

ios - MKAnnotationView layer is not of expected type: MKLayer -

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -