# Latin hypercube sampler¶

Welcome to the lhs documentation. This package implements a Latin hypercube sampler that extends pypfilt to support scenario modelling.

The code is distributed under the terms of the BSD 3-Clause license (see LICENSE), and the documentation is distributed under the terms of the Creative Commons BY-SA 4.0 license.

## Usage¶

Replace the default pypfilt sampler with lhs.Sampler in your scenario files:

[components]
sampler = "lhs.Sampler"


Define the prior distribution for each independent parameter:

[model.priors]
R0 = { function = "constant", args.value = 2.53, shape = 1 }
eta = { function = "loguniform", args.a = 0.05, args.b = 0.1, shape = 1 }


Define the name and size of each dependent parameter:

[model.dependent_priors]
alpha_m.shape = 1


Note

The distribution names and arguments must either match those defined in scipy.stats or those provided in lhs.dist (see Supported distributions). In particular, the scipy.stats distributions may accept shape parameters that are different from those provided by numpy.random.Generator.

Define the distribution for each dependent parameter, given the sampled values for every independent parameter, in the dependent_dists method of your simulation model:

class Model(pypfilt.Model):

def dependent_dists(self, indep_priors):
eta_values = indep_priors['eta']()
return {
'alpha_m': define_alpha_m_dist(eta_values),
}


Note

The prior functions created by the LHS sampler do not accept any arguments.

You may also want to add the lhs.LhsSamples summary table, which records the sampled values for every parameter:

[summary.tables]
lhs_samples.model = "lhs.LhsSamples"