MATLAB Answers

Stopping and restarting latin hypercube sampling

1 view (last 30 days)
Alessandro Murgia
Alessandro Murgia on 8 Feb 2021
Answered: Anshika Chaurasia on 11 Feb 2021
Hi!
I'm trying to run an analysis, in which my variables are sampled with the latin hypercube function lhdesign.
I'd like to stop my simulation when a stopping criteria is satisfied, therefore I'd like also to sample only the necessary points instead of preparing all the combinations before.
From what I know, random number generation ins't actually random, but it follows a kind of pattern (I'm not an expert).
My question is: if I stop the sampling and then I restart it, does the sampling restart from the last point, or also the generation algorithm restarts?
To be clearer, suppose I need to sample N points (N is not determined, since it depends on when the stopping criteria is satisfied), but I want these points to be sampled in groups of 100. So I sample the first 100 points, the I the computation I need to do, check the criterion, sample the next 100 points and so on.
After the first 100 sample, is the first sample of the second group a kind of 101th sample, or the sampling pattern restarts such that the first sample of the second group is the same of the first sample of the first group?
I know it's not explained ina very clear way, but thank you anyway.

Answers (1)

Anshika Chaurasia
Anshika Chaurasia on 11 Feb 2021
Hi Alessandro,
On running the following code:
rng default % For reproducibility
X = lhsdesign(10,4)
You will get the same samples eveytime you run above code because of the rng. Moreover, each column of X contains one random number in each interval [0,0.1], [0.1,0.2], [0.2,0.3], [0.3,0.4], [0.4,0.5], [0.5,0.6], [0.6,0.7], [0.7,0.8], [0.8,0.9], and [0.9,1].
On running the following code:
X = lhsdesign(10,4)
You will get different samples eveytime you run above code.
Refer to lhsdesign documentation.
Hope it helps!

Products


Release

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!