0

LHS method provides sampling values between zero to 1. If I want to set bounds, for example, for one dimension value should be -0 to 15? How can I do that in pyDOE python?

from pyDOE import *
n = 2
samples = 50

d = lhs(n, samples, criterion='center')
x1 = d[:,0]
x2 = d[:,1]

My x1 values should be between -10 to 10, and x2 should be 1 to 20.

2 Answers2

0

Multiple each data point in x1 (or x2) by the range of your bounds e.g. 10 - (-10) ie. 20, and add it to the lower bound.

x1_new = [None for i in range(len(x1))]
for i,j in enumerate(x1):
   x1_new[i] = -10 + 20*j

... I think?

EJay
  • 159
  • 4
0

I figured it out

import pyDOE as pyd
bounds = np.array([[-10,10],[1,20]]) #[Bounds]

# print(xbounds)
X = pyd.lhs(2, 100, criterion='centermaximin')

X[:,0] = (X[:,0]*(bounds[0,1]-bounds[0,0])+bounds[0,0])
X[:,1] = (X[:,1]*(bounds[1,1]-bounds[1,0])+bounds[1,0])