Misc

Miscellaneous utilities.

class active_subspaces.utils.misc.BoundedNormalizer(lb, ub)

A class for normalizing bounded inputs.

lb

ndarray

a matrix of size m-by-1 that contains lower bounds on the simulation inputs

ub

ndarray

a matrix of size m-by-1 that contains upper bounds on the simulation inputs

See also

utils.misc.UnboundedNormalizer

normalize(X)

Return corresponding points shifted and scaled to [-1,1]^m.

Parameters:X (ndarray) – contains all input points one wishes to normalize. The shape of X is M-by-m. The components of each row of X should be between lb and ub.
Returns:X_norm – contains the normalized inputs corresponding to X. The components of each row of X_norm should be between -1 and 1.
Return type:ndarray
unnormalize(X)

Return corresponding points shifted and scaled to [lb, ub].

Parameters:X (ndarray) – contains all input points one wishes to unnormalize. The shape of X is M-by-m. The components of each row of X should be between -1 and 1.
Returns:X_unnorm – contains the unnormalized inputs corresponding to X. The components of each row of X_unnorm should be between lb and ub.
Return type:ndarray
class active_subspaces.utils.misc.Normalizer

An abstract class for normalizing inputs.

normalize(X)

Return corresponding points in normalized domain.

Parameters:X (ndarray) – contains all input points one wishes to normalize
Returns:X_norm – contains the normalized inputs corresponding to X
Return type:ndarray

Notes

Points in X should be oriented as an m-by-n ndarray, where each row corresponds to an m-dimensional point in the problem domain.

unnormalize(X)

Return corresponding points shifted and scaled to [-1,1]^m.

Parameters:X (ndarray) – contains all input points one wishes to unnormalize
Returns:X_unnorm – contains the unnormalized inputs corresponding to X
Return type:ndarray

Notes

Points in X should be oriented as an m-by-n ndarray, where each row corresponds to an m-dimensional point in the normalized domain.

class active_subspaces.utils.misc.UnboundedNormalizer(mu, C)

A class for normalizing unbounded, Gaussian inputs to standard normals.

mu

ndarray

a matrix of size m-by-1 that contains the mean of the Gaussian simulation inputs

L

ndarray

a matrix size m-by-m that contains the Cholesky factor of the covariance matrix of the Gaussian simulation inputs.

See also

utils.misc.BoundedNormalizer

Notes

A simulation with unbounded inputs is assumed to have a Gaussian weight function associated with the inputs. The covariance of the Gaussian weight function should be full rank.

normalize(X)

Return points transformed to a standard normal distribution.

Parameters:X (ndarray) – contains all input points one wishes to normalize. The shape of X is M-by-m. The components of each row of X should be a draw from a Gaussian with mean mu and covariance C.
Returns:X_norm – contains the normalized inputs corresponding to X. The components of each row of X_norm should be draws from a standard multivariate normal distribution.
Return type:ndarray
unnormalize(X)

Transform points to original Gaussian.

Return corresponding points transformed to draws from a Gaussian distribution with mean mu and covariance C.

Parameters:X (ndarray) – contains all input points one wishes to unnormalize. The shape of X is M-by-m. The components of each row of X should be draws from a standard multivariate normal.
Returns:X_unnorm – contains the unnormalized inputs corresponding to X. The components of each row of X_unnorm should represent draws from a multivariate normal with mean mu and covariance C.
Return type:ndarray
active_subspaces.utils.misc.atleast_2d(A, oned_as='row')

Ensures the array A is at least two dimensions.

Parameters:
  • A (ndarray) – matrix
  • oned_as (str, optional) – should be either ‘row’ or ‘col’. It determines whether the array A should be expanded as a 2d row or 2d column (default ‘row’)
active_subspaces.utils.misc.atleast_2d_col(A)

Wrapper for atleast_2d(A, ‘col’)

Notes

Thanks to Trent Lukaczyk for these functions!

active_subspaces.utils.misc.atleast_2d_row(A)

Wrapper for atleast_2d(A, ‘row’)

Notes

Thanks to Trent Lukaczyk for these functions!

active_subspaces.utils.misc.conditional_expectations(f, ind)

Compute conditional expectations and variances for given function values.

Parameters:
  • f (ndarray) – an ndarry of function evaluations
  • ind (ndarray[int]) – index array that tells which values of f correspond to the same value for the active variable.
Returns:

  • Ef (ndarray) – an ndarray containing the conditional expectations
  • Vf (ndarray) – an ndarray containing the conditional variances

Notes

This function computes the mean and variance for all values in the ndarray f that have the same index in ind. The indices in ind correspond to values of the active variables.

active_subspaces.utils.misc.process_inputs(X)

Check a matrix of input values for the right shape.

Parameters:X (ndarray) – contains input points. The shape of X should be M-by-m.
Returns:
  • X (ndarray) – the same as the input
  • M (int) – number of rows in X
  • m (int) – number of columns in X
active_subspaces.utils.misc.process_inputs_outputs(X, f)

Check matrix of input values and a vector of outputs for correct shapes.

Parameters:
  • X (ndarray) – contains input points. The shape of X should be M-by-m.
  • f (ndarray) – M-by-1 matrix
Returns:

  • X (ndarray) – the same as the input
  • f (ndarray) – the same as the output
  • M (int) – number of rows in X
  • m (int) – number of columns in X