Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get the distribution of a parameter using Latin Hypercube Sampling that has bounds in different scales using Python?

I have an equation with three parameters namely a, b, and c. I am minimizing the parameters of this equation by comparing it to a measured behaviour. For this purpose, I am trying to generate a Latin Hypercube Sampling of three-dimensional parameter space (namely for a, b, and c) and want to use different samples as an initial guess for the minimization. Also, I want to generate these samples within bounds ((1e-15,1e-05), (1,5), (0,1)) for each parameter respectively.

I have the following code for the generation of scaled parameter space:

from scipy.stats import qmc
sampler = qmc.LatinHypercube(d=3)
sample = sampler.random(n=5)
print(sample)

which generates the following LHS:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>>> [[0.85448659 0.41801193 0.22357232]
 [0.00312924 0.18687008 0.65662771]
 [0.60861481 0.9413831  0.55522406]
 [0.56288569 0.38992472 0.93933801]
 [0.30978017 0.620607   0.19730746]]

Now, I scale them using qmc.scale as:

l_bounds = [1e-15, 1, 0]
u_bounds = [1e-05, 5, 1]
sample_scaled = qmc.scale(sample, l_bounds, u_bounds)
print(sample_scaled)

and the result is:

>>> [[8.54486593e-06 2.67204771e+00 2.23572322e-01]
 [3.12923556e-08 1.74748031e+00 6.56627715e-01]
 [6.08614807e-06 4.76553238e+00 5.55224057e-01]
 [5.62885688e-06 2.55969886e+00 9.39338009e-01]
 [3.09780166e-06 3.48242798e+00 1.97307459e-01]]

The problem is the first column of sample_scaled. If we look at it, we can see that the distribution in the scaled case for the first parameter is between the range 1e-8 to 1e-6. However, I want it to be distributed in between 1e-15 to 1e-05 (as specified in the code above). For the other two parameters, the scaled distribution is fine.

Can somebody point out the mistake or the problem here? and can guide me on how to correctly generate a distribution for this specific scenario?

>Solution :

Notice that the interval (1e-15-1e-8) about 1000 times smaller than the interval (1e-8-1e-5). If you want something to span over multiple orders of magnitude probably you want a logarithmic scale.

import numpy as np
from scipy.stats import qmc
sampler = qmc.LatinHypercube(d=3)
sample = sampler.random(n=5)
l_bounds = [np.log(1e-15), 1, 0]
u_bounds = [np.log(1e-5), 5, 1]
sample_scaled = qmc.scale(sample, l_bounds, u_bounds)
sample_scaled[:,0] = np.exp(sample_scaled[:,0])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading