ema workbench

Table Of Contents

Other Sub Sites

samplers

Created on 16 aug. 2011

This module contains various classes that can be used for specifying different types of samplers. These different samplers implement basic sampling techniques including Full Factorial sampling, Latin Hypercube sampling, and Monte Carlo sampling.

Code author: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>

Sampler

class samplers.Sampler

Bases: object

base class from which different samplers can be derived

distributions

types of distributions known by the sampler. by default it knows the uniform continuous distribution for sampling floats, and the uniform discrete distribution for sampling integers.

sample(distribution, params, size)

method for sampling a number of samples from a particular distribution. The various samplers differ with respect to their implementation of this method.

Parameters:
  • distribution – the distribution to sample from
  • params – the parameters specifying the distribution
  • size – the number of samples to generate
generate_design(uncertainties, size)

The main method of :class: ~sampler.Sampler and its children. This will call the sample method for each of the uncertainties and return the resulting designs.

Parameters:
Return type:

tuple with the designs as the first entry and the names of the uncertainties as the second entry.

LHSSampler

class samplers.LHSSampler

Bases: samplers.Sampler

generates a Latin Hypercube sample for each of the uncertainties in case of categorical uncertainties, it handles the transform as well

sample(distribution, params, size)

generate a Latin Hypercupe Sample.

Parameters:
  • distribution – the distribution to sample from
  • params – the parameters specifying the distribution
  • size – the number of samples to generate
_lhs(dist, parms, siz=100)

Latin Hypercube sampling of any distribution.

modified from code found online.

Parameters:
  • dist – random number generator from scipy.stats
  • parms – tuple of parameters as required for dist.
  • siz – number or shape tuple for the output sample

MonteCarloSampler

class samplers.MonteCarloSampler

Bases: samplers.Sampler

generates a Monte Carlo sample for each of the uncertainties. In case of a Categorical Uncertainty it also handles the transform

sample(distribution, params, size)

generate a Monte Carlo Sample.

Parameters:
  • distribution – the distribution to sample from
  • params – the parameters specifying the distribution
  • size – the number of samples to generate

FullFactorialSampler

class samplers.FullFactorialSampler

Bases: samplers.Sampler

generates a full factorial sample. If the uncertainty is non categorical, resolution is used to set the samples. If the uncertainty is an integer, their wont be duplicates in the sample. So, samples is equal to or smaller then the specified resolution

max_designs

max number of designs that is allowed (Default 50.000).

generate_design(uncertainties, size)

This method provides an alternative implementation to the default implementation provided by Sampler. This version returns a full factorial design across the uncertainties.

Parameters:
Return type:

tuple with the designs as the first entry and the names of the uncertainties as the second entry.

Note

The current implementation has a hard coded limit to the number of designs possible. This is set to 50.000 designs. If one want to go beyond this, set self.max_designs to a higher value.