Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
How can use Latin hypercube sampling to generate integer numbers?

Subject: How can use Latin hypercube sampling to generate integer numbers?

From: Morteza

Date: 12 Nov, 2012 19:51:12

Message: 1 of 4

Dear All,
Does anyone know how can use Latin Hypercube sampling to produce integer random samples?
I want to create 20 sets of data in the range of LB=[-1 -4 -3 1 2 4] and UB=[5 4 7 3 9 7].
With Regards


I used this code:

%lhsdesign
lb = [-1 -4 -3 1 2 4]; % lower bound
ub = [5 4 7 3 9 7; % upper bound
n = 20; % number of samples
p = 6; % number of parameters
xn = lhsdesign(n,p,'criterion','maximin'); % generate normalized design
x = floor(bsxfun(@plus,lb,bsxfun(@times,xn,(ub-lb))));
y= (bsxfun(@plus,lb,bsxfun(@times,xn,(ub-lb))));

Subject: How can use Latin hypercube sampling to generate integer numbers?

From: Roger Stafford

Date: 12 Nov, 2012 21:27:17

Message: 2 of 4

"Morteza " <m.kiani.74@gmail.com> wrote in message <k7rjvg$1h7$1@newscl01ah.mathworks.com>...
> Does anyone know how can use Latin Hypercube sampling to produce integer random samples?
> I want to create 20 sets of data in the range of LB=[-1 -4 -3 1 2 4] and UB=[5 4 7 3 9 7].
- - - - - - - - - - - - -
  The basic idea behind Latin hypercube sampling is that the range of each variable is to be divided into the same number of equally probable intervals. See:

 http://en.wikipedia.org/wiki/Latin_hypercube_sampling

  With your problem you are attempting to produce differing numbers of integers between the given lower and upper bounds, which would seem to violate the intent of Latin hypercube sampling. Moreover, doing a 'floor' (or a 'round' or a 'ceil') on the results as you have done will not in general even produce equally probable integers.

  For the sake of discussion, let us take only the first two variables, the first an integer from -1 to 5 and the second from -4 to 4, which makes 7 possibilities for the first and 9 for the second, and gives 63 possible combinations altogether. Which of these 63 combinations would you like to see allowed in a sampling? An answer commensurate with Latin hypercube sampling is not clear to me.

Roger Stafford

Subject: How can use Latin hypercube sampling to generate integer numbers?

From: Roger Stafford

Date: 13 Nov, 2012 02:29:13

Message: 3 of 4

"Roger Stafford" wrote in message <k7rpjl$n8q$1@newscl01ah.mathworks.com>...
> For the sake of discussion, let us take only the first two variables, the first an integer from -1 to 5 and the second from -4 to 4, which makes 7 possibilities for the first and 9 for the second, and gives 63 possible combinations altogether. Which of these 63 combinations would you like to see allowed in a sampling? An answer commensurate with Latin hypercube sampling is not clear to me.
- - - - - - - -
  I would like to replace that last paragraph which began with "for the sake of discussion" with the following, since the question I posed there was not quite pertinent.

  In choosing the "maximin" option you are attempting to move the closest of your 20 six-dimensional points as far apart as possible. Unfortunately when you do rescaling based on 'lb' and 'ub' which differs on each of the six variables and when you alter them to nearby integers, that renders these distance calculations somewhat inappropriate. It isn't clear just what you are optimizing this way.

  Also note that with the 'floor' action you can never attain integers in the upper bound values. That is, 5, 4, 7, 3, 9, and 7 will each never occur in the respective six variables in your x sample.

Roger Stafford

Subject: How can use Latin hypercube sampling to generate integer numbers?

From: Rashmi B

Date: 14 Jul, 2014 15:03:07

Message: 4 of 4

Sir,
I am in a similar situation like the author of this question. I need to sample using Latin Hypercube, a number of discrete and continuous variables whose lower and upper bounds are given.
What do you suggest is the best method to follow here?

Thanks in advance,
Rashmi

"Roger Stafford" wrote in message <k7sb9p$mbv$1@newscl01ah.mathworks.com>...
> "Roger Stafford" wrote in message <k7rpjl$n8q$1@newscl01ah.mathworks.com>...
> > For the sake of discussion, let us take only the first two variables, the first an integer from -1 to 5 and the second from -4 to 4, which makes 7 possibilities for the first and 9 for the second, and gives 63 possible combinations altogether. Which of these 63 combinations would you like to see allowed in a sampling? An answer commensurate with Latin hypercube sampling is not clear to me.
> - - - - - - - -
> I would like to replace that last paragraph which began with "for the sake of discussion" with the following, since the question I posed there was not quite pertinent.
>
> In choosing the "maximin" option you are attempting to move the closest of your 20 six-dimensional points as far apart as possible. Unfortunately when you do rescaling based on 'lb' and 'ub' which differs on each of the six variables and when you alter them to nearby integers, that renders these distance calculations somewhat inappropriate. It isn't clear just what you are optimizing this way.
>
> Also note that with the 'floor' action you can never attain integers in the upper bound values. That is, 5, 4, 7, 3, 9, and 7 will each never occur in the respective six variables in your x sample.
>
> Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us