sahilm89 / lhsmdu

This is an implementation of Deutsch and Deutsch, "Latin hypercube sampling with multidimensional uniformity", Journal of Statistical Planning and Inference 142 (2012) , 763-772
MIT License
79 stars 16 forks source link

lhsmdu to work with scipy distributions (and ranges) #6

Closed MatthiVH closed 3 years ago

MatthiVH commented 4 years ago

Hi there,

When creating samples with lhsmdu, is there a way to do it not uniformly but according to some/all of the scipy distributions (e.g., normal, alpha, beta, lognormal, ... about 100 different distributions are in scipy).

Ideally would be to have something that sets the distribution and range for each of the variables, then an amount of samples which is obviously equal for all variables and to do latin-hypercube or MC based on that. I'm just thinking out loud by the way as someone who uses it to do simulation analyses (not as a programmer).

Kind regards

sahilm89 commented 4 years ago

@MatthiVH Hi, please check the README for sampling from arbitrary CDFs. I've put up an example (with a Gaussian) there that shows exactly this. Essentially, the idea is to use the uniformly sampled n-dimensions returned by the lhsmdu and using that to sample from CDF for the distribution of interest. The function inverseTransformSample should do it for you. Let me know if you face any trouble with it. Best, Sahil

MatthiVH commented 4 years ago

Hi Sahil,

Yes, this works, some example info or scripts on how to use the code for often used applications of it is always handy for new visitors of the package (or new lhs/mc users like me a month ago). But this seems to be there now, so that's really helpful! Thanks!

Kind regards, Matthias

sahilm89 commented 3 years ago

Closing this issue.