naught101 / sobol_seq

python implementation of Sobol' sequence generator
MIT License
67 stars 29 forks source link

seed for i4_sobol_generate #8

Closed wb2012sf closed 8 years ago

wb2012sf commented 8 years ago

Hi, I am not really clued up on how to report findings here, so I just try this. The current definition of the function i4_sobol_generate is as follows:

def i4_sobol_generate(dim_num, n, skip=1):
    """
    i4_sobol_generate generates a Sobol dataset.
    Parameters:
      Input, integer dim_num, the spatial dimension.
      Input, integer N, the number of points to generate.
      Input, integer SKIP, the number of initial points to skip.
      Output, real R(M,N), the points.
    """
    r = np.full((n, dim_num), np.nan)
    for j in range(n):
        seed = j + 1
        r[j, 0:dim_num], next_seed = i4_sobol(dim_num, seed)

    return r

As I see it, the seed for the i4_sobol() call should be j+skip, not j+1. seed = j + skip Otherwise there is no way to apply a different seed, or am I missing something? Apologies if I am completely off. Best Regards

naught101 commented 8 years ago

I think you're correct, yes. Do you want to make a pull request with that change?

wb2012sf commented 8 years ago

I just just did, there was actually a second instance of the seed being ignored. I changed that as well. You'll see it in the pull request. Thanks for letting me do this, I learned a lot :-)

naught101 commented 8 years ago

Thanks, merged in https://github.com/naught101/sobol_seq/pull/9/commits/b120995d6dbfde72ec5e6661613861cf2130ebf7