i4_sobol_generate ignores skip parameter
lbrichards opened this issue · comments
in i4_sobol_generate() I think you need to add + skip on line 131 as follows:
seed = j + 1 + skip
Currently skip has no effect.
What version of the code are you looking at?
sobol_seq/sobol_seq/sobol_seq.py
Line 127 in 6ac1799
Understood, and thanks for the clarification. My default way of installing dependencies is pip, but I can of course clone in this case.
BTW, this is probably not the appropriate place to discuss, and I hope you don't mind my asking, but the i4_sobol function contains a self
, as though someone intended it to be a class. Indeed, it seems to be a function wanting to be a class, since unless there is a class instance the self.seed_save
will not be remembered from one function call to the next. Someone, it seems, intended for this function to remember its most recent seed upon each call. I presume this was to save computation time when a very large seed is used. I would be happy to propose some refactoring, if you're open to such an idea. Essentially I would propose a rewrite as
class i4_sobol(object):
def __init__(self, dim_num, seed ):
and add a __call__
method allowing it to retain its function-like behavior.
I basically uploaded this because I wanted to make some minor changes and make it easier for others to install it. Now, looking through the code, I'm a bit surprised I didn't already do that. I unfortunately don't have time to work on this at the moment, but I'm more than happy to accept pull requests, ideally with backwards compatibility.
It would be especially sensible to move all those globals into class attributes. Not sure where you're seeing a self
, but yes, I think that would be a great idea.
The i4_*
syntax is a hang-over from Fortran, it could also be removed, although it would be good to leave those functions there as wrappers with deprecation warnings.
Kudos to you for taking the first initiative. I would love to contribute to such a worthy cause. I have found several variants of this code, but none very Pythonic, and none -- as far as I can tell -- takes advantage of the Gray code efficiency boost by Antonov and Saleev. For my simulations I need to find long pairs of Sobol sequences that have approximately zero correlation, and this is very time consuming. Not sure how much the Gray code implementation would speed things up, but it's worth a try. And making things less Fortran-like and more Pythonic is also nice. I will aim to send you some pull requests after I escape some deadlines...