pyDOE
pyDOE copied to clipboard
Seed for latin hypercube
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
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]])
The above does not seem to work (anymore). pyDOE2 has an option to pass a 'random_state' value though.