Skip to content

Same seed in Multiprocessing for numpy #13

@jakgel

Description

@jakgel

Hello,
I encountered inconsistent behaviour for random processes within the generator when using multiprocessing for abcpmc.Sampler(..., postfn = testrand, ... )

`

def testrand():
    import random
    import numpy as np
    random.randrange(1000)                   # Is random
    np.random.randint(1000, size=1)       # yields same results for every process
    np.random.poisson(1000,10)              # yields same results for every process
    return 0

`

One possible workaround is to use random to set a random seed for numpy within the function:

seed = random.randrange(4294967295)
np.random.seed(seed=seed)

however this is bulky and might confuse some users that might not know about this behaviour.
Could you please consider adapting abcpmc to also exhibit the random behavior for numpy.random?

Thanks
jakgel

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions