Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python : Halton and Hammersley quasi random sequences

I am trying to construct Hammersley and Halton quasi random sequences. I have for example three variables x1, x2 and x3. They all have integer values. x1 has a range from 2-4, x2 from 2-4 and x3 from 1-7. Is there any python package which can create those sequences? I saw that there are some procject like sobol or SALib, but they do not implemented Halton and Hammersley.

Best regards

like image 695
Varlor Avatar asked Oct 26 '25 07:10

Varlor


2 Answers

Most library methods offering low discrepancy methods for arbitrary dimensions, won’t include arguments that allow you to define arbitrary intervals for each of the separate dimensions/components. However, in virtually all of these cases, you can adapt the exisiting method to suit your requirements with the addition of a single line of code. Understanding this will dramatically increase number of librbaries you can choose to use!

For nearly all low discrepancy (quasirandom) sequences, each term is equidistributed in the half open range [0,1). Similarly, for d-dimensional sequences, each component of each term falls in [0,1).

This includes the Halton sequence ( which is a generalization if the van der Corput), Hammersley, Weyl/Kronecker, Sobol, and Niederreiter sequences.

Converting a value from [0,1) to [a,b) can be achieved, via the linear transformation x = a + (b-a) z. Thus if the n-th term of the canonical low discrepancy sequence is (z_1,z_2,z,z_3), then you desired sequence is (2+2*z1, 2+2*z2, 1+6*z3).

like image 121
2 revsMartin Roberts Avatar answered Oct 28 '25 21:10

2 revsMartin Roberts


Starting with SciPy 1.7 you have a Sobol' and Halton low discrepancy sequences in SciPy. There is also a convenient function scale that can be used to scale the values to given bounds.

https://scipy.github.io/devdocs/reference/stats.qmc.html

like image 33
tupui Avatar answered Oct 28 '25 21:10

tupui



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!