[Python] Problems with repeated draws of Sobol sequence in scipy

Discussão em 'Python' iniciado por Stack, Agosto 13, 2025.

  1. Stack

    Stack Membro Participativo

    How do I get unique (uncorrelated) Sobol sequences by making repeated calls to random or random_base2?

    I'm trying to repeatedly generate 'random' Sobol sequences, but I'm getting the same sequence each time. My reading of the documentation suggested that repeated calls would give me a different sequence ("To continue an existing design, extra points can be obtained by calling again random_base2.").

    Here's my code:

    import scipy
    engine2 = scipy.stats.qmc.Sobol(d=1, scramble=True)
    sample_qmc1 = engine2.random_base2(m=14)
    print(sample_qmc1)
    sample_qmc2 = engine2.random_base2(m=14)
    print(sample_qmc2)


    Here's example output:

    [[0.2534843 ]
    [0.884218 ]
    [0.69113704]
    ...
    [0.69106254]
    [0.88420477]
    [0.25347106]]
    [[0.25342032]
    [0.88416122]
    [0.69107275]
    ...
    [0.69111674]
    [0.88426601]
    [0.2535251 ]]


    As you can see, the values are almost the same.

    reset() doesn't help, I get the same sequence. Changing to random() doesn't help either. Using smaller sample sizes does seem to work.

    If I add this line:

    sample_qmc3 = engine2.random_base2(m=14)


    I get this error:

    ValueError: The balance properties of Sobol' points require n to be a power of 2. 24576 points have been previously generated, then: n=24576+2**14=40960. If you still want to do this, the function 'Sobol.random()' can be used.


    I tried LatinHypercube and it doesn't have this problem.

    I'm using scipy 1.14.1

    Anyone go any ideas how I can generate unique Sobol sequences?

    Continue reading...

Compartilhe esta Página