tisimst / pyDOE

Design of experiments for Python
BSD 3-Clause "New" or "Revised" License
261 stars 114 forks source link

Seed for latin hypercube #16

Open iamholger opened 6 years ago

iamholger commented 6 years ago

Hi, I am playing with the latin hypercube samper and was wondering if there is a way to set the random seed somewhere. Thanks, Holger

willblatt commented 6 years ago

Calling np.random.seed() before each call should do it.

>>> import numpy as np
>>> import pyDOE
>>> pyDOE.lhs(2, 5)
array([[ 0.70104734,  0.67737853],
       [ 0.04406124,  0.24034865],
       [ 0.52808135,  0.06996526],
       [ 0.95872749,  0.91600084],
       [ 0.2935575 ,  0.49661397]])
>>> pyDOE.lhs(2, 5)
array([[ 0.37079506,  0.6130573 ],
       [ 0.70104922,  0.29884737],
       [ 0.5693123 ,  0.81930618],
       [ 0.88562447,  0.15706703],
       [ 0.03688797,  0.4159291 ]])
>>> np.random.seed(2)
>>> pyDOE.lhs(2, 5)
array([[ 0.64092973,  0.28706448],
       [ 0.48407356,  0.85336546],
       [ 0.3099325 ,  0.00518525],
       [ 0.08719898,  0.46606696],
       [ 0.85993093,  0.72385419]])
>>> np.random.seed(2)
>>> pyDOE.lhs(2, 5)
array([[ 0.64092973,  0.28706448],
       [ 0.48407356,  0.85336546],
       [ 0.3099325 ,  0.00518525],
       [ 0.08719898,  0.46606696],
       [ 0.85993093,  0.72385419]])
judejeh commented 2 years ago

The above does not seem to work (anymore). pyDOE2 has an option to pass a 'random_state' value though.