python - computing cost of np.random.uniform vs np.random.beta -


i have algorithm uses np.random.uniform switch np.random.beta and/or np.random.gamma improve efficiency of approximation. since algorithm quite time consuming (~8hours) , memory intensive (5 gb per thread) wanted check if there information on how cost me before tried run.

since called inside loop, should assume not going change memory requirements?

what difference in run time?

just test using ipython:

in [1]: import numpy np  in [2]: %timeit np.random.random(1000) 100000 loops, best of 3: 9.25 µs per loop  in [3]: %timeit np.random.beta(0.5, 0.5, 1000) 10000 loops, best of 3: 45.3 µs per loop 

this imply factor of 5, appears depend on parameters of beta.

nevertheless, before drawing conclusions, should sure random number generation time-limiting factor algorithm. run profiler find out real bottlenecks are.


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo