gpmp.misc.designs module

The gpmp.misc.designs module provides simple design-of-experiments helpers. All design functions use NumPy arrays. Boxes are represented as [lower, upper] with shape (2, d).

Use regulargrid for tensor grids, randunif for independent uniform points, and ldrandunif/maximinlhs/maximinldlhs for low-discrepancy or Latin-hypercube designs. Distance helpers such as mindist, maxdist, and filldist_approx summarize point-set geometry.

Design of experiments utilities.

gpmp.misc.designs.discrepancy(sample)[source]

Calculate the discrepancy of the sample.

Parameters:

sample (numpy.ndarray) – Array of points in the sample.

Returns:

Discrepancy value of the sample.

Return type:

float

gpmp.misc.designs.filldist_approx(sample, box, n=1000000, x=None)[source]

Approximate the fill distance using a random uniform discretization of the box.

Parameters:
  • sample (numpy.ndarray) – Array of points in the sample.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

  • n (int, optional) – Number of points in the random uniform discretization, default is 1e6.

  • x (numpy.ndarray, optional) – Points in the random uniform discretization, default is None.

Returns:

Approximated fill distance.

Return type:

float

gpmp.misc.designs.ldrandunif(dim, n, box, max_iter=50)[source]

Generate a low discrepancy random uniform sample in the specified box.

Parameters:
  • dim (int) – Number of dimensions.

  • n (int) – Number of points in the sample.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

  • max_iter (int, optional) – Maximum number of iterations for optimization, default is 50.

Returns:

Low discrepancy random uniform sample in the specified box.

Return type:

numpy.ndarray

Notes

FIXME: optimization method

gpmp.misc.designs.maxdist(sample)[source]

Calculate the maximum distance (diameter) between any pair of points in the sample.

Parameters:

sample (numpy.ndarray) – Array of points in the sample.

Returns:

Maximum distance between any pair of points in the sample.

Return type:

float

gpmp.misc.designs.maximinldlhs(dim, n, box)[source]

Generate a maximin low-discrepancy Latin Hypercube Sample (LHS) within the specified box.

Parameters:
  • dim (int) – Number of dimensions.

  • n (int) – Number of points in the sample.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

Returns:

Maximin low-discrepancy Latin Hypercube Sample within the specified box.

Return type:

numpy.ndarray

gpmp.misc.designs.maximinlhs(dim, n, box, max_iter=1000)[source]

Generate a maximin Latin Hypercube Sample (LHS) within the specified box.

Parameters:
  • dim (int) – Number of dimensions.

  • n (int) – Number of points in the sample.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

  • max_iter (int, optional) – Maximum number of iterations for finding the sample with the maximum minimum distance, default is 1000.

Returns:

Maximin Latin Hypercube Sample within the specified box.

Return type:

numpy.ndarray

gpmp.misc.designs.mindist(sample)[source]

Calculate the minimum distance (separation) between any pair of points in the sample.

Parameters:

sample (numpy.ndarray) – Array of points in the sample.

Returns:

Minimum distance between any pair of points in the sample.

Return type:

float

gpmp.misc.designs.randunif(dim, n, box)[source]

Generate a random uniform sample in the specified box.

Parameters:
  • dim (int) – Number of dimensions.

  • n (int) – Number of points in the sample.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

Returns:

Random uniform sample in the specified box.

Return type:

numpy.ndarray

gpmp.misc.designs.regulargrid(dim, n, box)[source]

Build a regular grid in the dim-dimensional hyperrectangle.

If n is an integer, a grid of size n^dim is built;

If n is a list of length dim, a grid of size prod(n) is built, with n_i points on coordinate i.

The dim-dimensional hyperrectangle is specified by the argument box, which is a 2 x dim array where box_(1, i) and box_(2, i) are the lower- and upper-bound of the interval on the i^th coordinate.

Parameters:
  • dim (int) – Number of dimensions.

  • n (int or list) – Number of points per dimension or a list with the number of points per dimension.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

Returns:

x – Regular grid in the dim-dimensional hyperrectangle.

Return type:

numpy.ndarray

gpmp.misc.designs.scale(sample_standard, box)[source]

Map a standard sample in [0, 1]^dim to the given box.

Parameters:
  • sample_standard (numpy.ndarray) – Array of points in the standard sample.

  • box (list of lists) – List of lists containing the lower and upper bounds of the box.

Returns:

Sample points mapped to the given box.

Return type:

numpy.ndarray