rc.data.samples§
Functionality for Design of Experiments (DOE) and sampling.
Classes§
Sampling methods for inputs. |
|
Sample multivariate, zero-mean Gaussian noise. |
|
Sample a |
Methods§
|
Provide a rotation matrix which reorders axes. Most use cases are to re-order input axes according to GSA. |
|
Perform Principal Component Analysis on a Repo. |
Module Contents§
- class DOE[source]§
Sampling methods for inputs.
- static latin_hypercube(N, M, is_centered=True, **kwargs)[source]§
Latin Hypercube DOE.
- Parameters:
N (int) – The number of samples (rows).
M (int) – The of input dimensions (columns).
is_centered (bool) – Boolean ordinate whether to centre each sample in its Latin Hypercube cell. Default is False, which locates the sample randomly within its cell.
kwargs – Passed directly to scipy.stats.qmc.LatinHypercube.
Returns: An (N,M) matrix of N samples of dimension M.
- static full_factorial(N, M)[source]§
Full factorial DOE.
- Parameters:
N (int) – The number of samples (rows).
M (int) – The of input dimensions (columns).
Returns: An (N,M) matrix of N samples of dimension M.
- static space_filling_test(X, o)[source]§
Test whether
X
is a space-filling design matrix, by finding the distance to the nearest point inX
foro
test points.- Parameters:
X (rc.base.Np.Matrix) – An (N,M) design matrix.
o (int) – The number of test points used to assess whether
X
is a space-filling design.
- Return type:
rc.base.Dict[str, float]
- Returns: A dict of six measures: The theoretical hard upper bound, expected upper bound and
expected lower bound for a perfectly space-filling design matrix, followed by the max, mean and SD of the distance-to-nearest-in-X over the o test points.
- class GaussianNoise(N, variance)[source]§
Sample multivariate, zero-mean Gaussian noise.
- Parameters:
N (int)
variance (rc.base.Np.MatrixLike)
- class Variance(L, magnitude, is_covariant=False, is_determined=True)[source]§
An artificially generated (co)variance matrix for GaussianNoise, with a useful labelling scheme.
- Parameters:
L (int)
magnitude (float)
is_covariant (bool)
is_determined (bool)
- property matrix: rc.base.Np.Matrix§
Variance as an (L,L) covariance matrix, suitable for constructing GaussianNoise.
- Return type:
rc.base.Np.Matrix
- property meta: rc.base.Dict[str, rc.base.Any]§
Meta matching the initials in
self.__format__()
.- Return type:
rc.base.Dict[str, rc.base.Any]
- __call__()[source]§
Variance as an (L,L) covariance matrix, suitable for constructing GaussianNoise. The constructor generates the matrix (perhaps stochastically), so repeated calls to any methods produce identical Variance.
- Return type:
rc.base.Np.Matrix
- __format__(format_spec)[source]§
The label for this Variance, to help name samples informatively. The description is
d.
(determined) oru.
(undetermined), followed byv.
(diagonal variance) orc.
(non-diagonal covariance), followed by100 * self.magnitude:.2f
.- Parameters:
format_spec (rc.base.Any)
- Return type:
str
- __call__(repo=None)[source]§
Generate N samples of L-dimensional Gaussian noise, sampled from \(N[0,self.variance]\). The constructor generates the sample, so repeated calls to any method always refer to the same GaussianNoise.
- Parameters:
repo (Repo | None) – An optional Repo which will have GaussianNoise added to Y in data.csv.
- Return type:
rc.base.Np.Matrix
Returns: An (N,L) noise matrix, where (L,L) is the shape of self._variance.
- class Function(root, doe, function_vector, N, M, noise_variance, ext=None, overwrite_existing=False, **kwargs)[source]§
Sample a
task.function.Vector
.- Parameters:
root (rc.base.Path | str)
doe (DOE)
function_vector (Vector)
N (int)
M (int)
noise_variance (GaussianNoise)
ext (str | None)
overwrite_existing (bool)
kwargs (rc.base.Any)
- collection(sub_folder)[source]§
Construct a Dict for task.results.Collect, with appropriate
extra_columns
.- Parameters:
folder – The folder under
self.repo.folder
housing the csvs to collect.sub_folder (rc.base.Union[rc.base.Path, str])
- Return type:
rc.base.Dict[str, rc.base.Any]
Returns: The Dict for
self.repo
.
- permute_axes(new_order)[source]§
Provide a rotation matrix which reorders axes. Most use cases are to re-order input axes according to GSA.
- Parameters:
new_order (rc.base.Sequence | None) – A Tuple or List containing a permutation of
[0,...,M-1]
, for passing tonp.transpose
.- Return type:
rc.base.Np.Matrix | None
Returns: A rotation matrix which will reorder the axes to new_order. Returns
None
ifnew_order is None
.
- PCA(root, csv)[source]§
Perform Principal Component Analysis on a Repo.
- Parameters:
root (str | rc.base.Path) – The root folder.
csv (str | rc.base.Path) – The csv to read.
normalization – An optional csv file to use for normalization.
- Return type:
rc.base.Path
Returns: The folder written to, namely root``/PCA``