Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generating low discrepancy quasi-random sequences in python/numpy/scipy?

There is already a question on this but the answer contains a broken link, and being over two years old, I'm hoping there's a better solution now :)

Low discrepancy quasi-random sequences, e.g. Sobol sequences, fill a space more uniformly than uniformly random sequences. Is there a good/easy way to generate them in python?

like image 809
rhombidodecahedron Avatar asked Jun 26 '14 15:06

rhombidodecahedron


3 Answers

I think the best alternative for Low Discrepancy sequences in Python is Sensitivity Analysis Library (SALib):

https://github.com/SALib/SALib

I think this is an active project and you can contact the author to check if the functionalities you need are already implemented. If that doesn't solve your problem, Corrado Chisari ported a SOBOL version made in Matlab (by John Burkardt) to Python, you can access it here:

http://people.sc.fsu.edu/~jburkardt/py_src/sobol/sobol.html

Someone cleaned up the comments in these sources and put them in the format of docstrings. It's much more readable and you can access it here:

https://github.com/naught101/sobol_seq

like image 100
renatov Avatar answered Nov 05 '22 18:11

renatov


Scipy has this option now http://scipy.github.io/devdocs/generated/scipy.stats.qmc.Sobol.html

PyTorch also proves option of generating sobol random numbers. It allows upto a dimension of ~1k and has an option to switch on scrambling. https://pytorch.org/docs/stable/generated/torch.quasirandom.SobolEngine.html

like image 43
toing Avatar answered Nov 05 '22 17:11

toing


Chaospy is also a valid option. One can select several approaches for low-discrepancy sampling (including 'Sobol, latin hypercube, etc) - for more details see the documentation.

like image 1
Sam Avatar answered Nov 05 '22 17:11

Sam