sampling.design.fullfactorial

sampling.design.fullfactorial(q, Edges=1)

Generates a full factorial sampling plan in the unit cube.

Parameters

Name Type Description Default
q list or np.ndarray A list or array containing the number of points along each dimension (k-vector). required
Edges int Determines spacing of points. If Edges=1, points are equally spaced from edge to edge (default). Otherwise, points will be in the centers of n = q[0]q[1]…*q[k-1] bins filling the unit cube. 1

Returns

Name Type Description
np.ndarray Full factorial sampling plan as an array of shape (n, k), where n is the total number of points and k is the number of dimensions.

Raises

Name Type Description
ValueError If any dimension in q is less than 2.

Notes

Many thanks to the original author of this code, A Sobester, for providing the original Matlab code under the GNU Licence. Original Matlab Code: Copyright 2007 A Sobester: “This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU General Public License and GNU Lesser General Public License along with this program. If not, see http://www.gnu.org/licenses/.”

Examples

>>> from spotpython.utils.sampling import fullfactorial
>>> q = [3, 2]
>>> X = fullfactorial(q, Edges=0)
>>> print(X)
        [[0.         0.        ]
        [0.         0.75      ]
        [0.41666667 0.        ]
        [0.41666667 0.75      ]
        [0.83333333 0.        ]
        [0.83333333 0.75      ]]
>>> X = fullfactorial(q, Edges=1)
>>> print(X)
        [[0.  0. ]
        [0.  1. ]
        [0.5 0. ]
        [0.5 1. ]
        [1.  0. ]
        [1.  1. ]]