The GPParams Module

class mogp_emulator.GPParams.CorrTransform

Class representing correlation length transforms

mogp_emulator performs coordinate transforms on all correlation length parameters to stabilize the fitting routines. The scaled correlation length \(l\) is related to the raw parameter \(\theta\) as follows:

:math:`{l = \exp(-0.5\theta)}`

This class groups together the coordinate transforms used for correlation length parameters as a collection of static methods. One does not need to create an object to use it, but this conveniently groups together all methods (in the event that multiple transforms are needed to perform a calculation). Collected methods are:

  • transform (convert raw parameter to scaled)
  • inv_transform (convert scaled parameter to raw)
  • dscaled_draw (compute derivative of scaled with respect to raw, as a function of the scaled parameter)
  • d2scaled_draw2 (compute second derivative of scaled with respect to raw, as a function of the scaled parameter)

The derivative functions take the scaled parameter as input due to the internal details of the required calculations. If you wish to compute the derivative using the raw parameter as the input, apply the provided transform method to the parameter first.

static d2scaled_draw2(s)

Compute second derivative of the scaled parameter with respect to the raw (as a function of the scaled parameter).

Parameters:s (float) – Input scaled parameter
Returns:transform second derivative of scaled with respect to raw
Return type:float
static dscaled_draw(s)

Compute derivative of the scaled parameter with respect to the raw (as a function of the scaled parameter).

Parameters:s (float) – Input scaled parameter
Returns:transform derivative of scaled with respect to raw
Return type:float
static inv_transform(s)

Convert scaled parameter to raw

Parameters:s (float) – Input scaled parameter
Returns:raw parameter
Return type:float
static transform(r)

Convert raw parameter to scaled

Parameters:r (float) – Input raw parameter
Returns:scaled parameter
Return type:float
class mogp_emulator.GPParams.CovTransform

Class representing covariance and nugget transforms

mogp_emulator performs coordinate transforms on all correlation length parameters to stabilize the fitting routines. The scaled covariance \(\sigma^2\) or scaled nugget \(\eta\) is related to the scaled parameter \(\theta\) as follows:

:math:`{\sigma^2 = \exp(\theta)}` (for covariance), or
:math:`{\eta = \exp(\theta)}` (for nugget)

This class groups together the coordinate transforms used for correlation length parameters as a collection of static methods. One does not need to create an object to use it, but this conveniently groups together all methods (in the event that multiple transforms are needed to perform a calculation). Collected methods are:

  • transform (convert raw parameter to scaled)
  • inv_transform (convert scaled parameter to raw)
  • dscaled_draw (compute derivative of scaled with respect to raw, as a function of the scaled parameter)
  • d2scaled_draw2 (compute second derivative of scaled with respect to raw, as a function of the scaled parameter)

The derivative functions take the scaled parameter as input due to the internal details of the required calculations. If you wish to compute the derivative using the raw parameter as the input, apply the provided transform method to the parameter first.

static d2scaled_draw2(s)

Compute second derivative of the scaled parameter with respect to the raw (as a function of the scaled parameter).

Parameters:s (float) – Input scaled parameter
Returns:transform second derivative of scaled with respect to raw
Return type:float
static dscaled_draw(s)

Compute derivative of the scaled parameter with respect to the raw (as a function of the scaled parameter).

Parameters:s (float) – Input scaled parameter
Returns:transform derivative of scaled with respect to raw
Return type:float
static inv_transform(s)

Convert scaled parameter to raw

Parameters:s (float) – Input scaled parameter
Returns:raw parameter
Return type:float
static transform(r)

Convert raw parameter to scaled

Parameters:r (float) – Input raw parameter
Returns:scaled parameter
Return type:float
class mogp_emulator.GPParams.GPParams(n_mean=0, n_corr=1, nugget='fit')

Class representing parameters for a GaussianProcess object

This class serves as a wrapper to a numpy array holding the parameters for a GaussianProcess object. Because the parameters for a GP are transformed in different ways (depending on convention and positivity constraints), the raw parameter values are often fairly opaque. This class provides more clarity on the raw and transformed parameter values used in a particular GP.

The class is a wrapper around the numpy array holding the raw data values. When initializing a new GPParams object, the data can optionally be specified to initialize the array. Otherwise, a default value of None will be used to indicate that the GP has not been fit.

Parameters:
  • n_mean (int) – The number of parameters in the mean function. Optional, default is 0 (zero or fixed mean function). Must be a non-negative integer.
  • n_corr (int) – The number of correlation length parameters. Optional, default is 1. This must be the same as the number of inputs for a particular GP. Must be a positive integer.
  • nugget (str or float) – String or float specifying how nugget is fit. If a float, a fixed nugget is used (and will fix the value held in the GPParams object). If a string, can be 'fit', 'adaptive', or 'pivot'.

The transformations between the raw parameters \(\theta\) and the transformed ones \((\beta, l, \sigma^2, \eta^2)\) are as follows:

  1. Mean: No transformation; \({\beta = \theta}\)
  2. Correlation: The raw values are transformed via \({l = \exp(-0.5\theta)}\) such that the transformed values are the correlation length associated with the given input.
  3. Covariance: The raw value is transformed via \({\sigma^2 = \exp(\theta)}\) so that the transformed value is the covariance.
  4. Nugget: The raw value is transformed via \({\eta^2 = \exp(\theta)}\) so that the transformed value is the variance associated with the nugget noise.
corr

Transformed correlation length parameters

The corr property returns the part of the data array, with transformation, associated with the correlation lengths. Transformation is done via via \({l = \exp(-0.5\theta)}\). Returns a numpy array of length (n_corr,) or None if the data array has not been initialized.

Can be set with a new numpy array of the correct length. New parameters must satisfy the positivity constraint and all be \(> 0\). If the data array has not been initialized, then setting individual parameter values cannot be done.

Returns:Numpy array holding the transformed correlation parameters
Return type:ndarray
corr_raw

Raw Correlation Length Parameters

This is used in computing kernels as the kernels perform the parameter transformations internally.

cov

Transformed covariance parameter

The cov property returns the covariance transformed according to \(\sigma^2=\exp(\theta)\). Returns a float or None if the data array has not been initialized.

Can be set with a new float \(>0\) or numpy array of length 1 holding a positive float. If the data array has not been initialized, then setting individual parameter values cannot be done.

Returns:Transformed covariance parameter
Return type:float or None
cov_index

Determine the location in the data array of the covariance parameter

get_data()

Returns current value of raw parameters as a numpy array

Provides access to the underlying data array for the GPParams object. Returns a numpy array or None if the parameters of this object have not yet been set.

Returns:Numpy array holding the raw parameter values
Return type:ndarray or None
mean

Mean parameters

The mean property returns the part of the data array associated with the mean function. Returns a numpy array of length (n_mean,) or None if the mean data has not been initialized.

Can be set with a new numpy array of the correct length.

Returns:Numpy array holding the mean parameters
Return type:ndarray
n_params

Number of fitting parameters stored in data array

This is the number of correlation lengths plus one (for the covariance) and optionally an additional parameter if the nugget is fit.

nugget

Transformed nugget parameter

The nugget property returns the nugget transformed via \(\eta^2=\exp(\theta)\). Returns a float or None if the emulator parameters have not been initialized or if the emulator does not have a nugget.

Can be set with a new float \(>0\) or numpy array of length 1. If the data array has not been initialized or the emulator has no nugget, then the nugget setter will return an error.

Returns:Transformed nugget parameter
Return type:float or None
nugget_type

Method used to fit nugget

Returns:string indicating nugget fitting method, either "fixed", "adaptive", "pivot", or "fit"
Return type:str
same_shape(other)

Test if two GPParams objects have the same shape

Method to check if a new GPParams object or numpy array has the same length as the current object. If a numpy array, assumes that the array represents the fitting parameters and that the mean parameters will be handled separately. If a GPParams object, it will also check if the number of mean parameters match.

Returns a boolean if the number of mean (if a GPParams object only), correlation, and nugget parameters (for a numpy array or a GPParams object) are the same in both object.

Parameters:other (GPParams or ndarray) – Additional instance of GPParams or ndarray to be compared with the current one.
Returns:Boolean indicating if the underlying arrays have the same shape.
Return type:bool
set_data(new_params)

Set a new value of the raw parameters

Allows the data underlying the GPParams object to be set at once. Can also be used to reset the underlying data to None for the full array, indicating that no parameters have been set. Note that setting the data re-initializes the mean and (if necessary) covariance and nugget.

Parameters:new_params (ndarray or None) – New parameter values as a numpy array with shape (n_params,) or None.
Returns:None
class mogp_emulator.GPParams.GPParams(n_mean=0, n_corr=1, nugget='fit')

Class representing parameters for a GaussianProcess object

This class serves as a wrapper to a numpy array holding the parameters for a GaussianProcess object. Because the parameters for a GP are transformed in different ways (depending on convention and positivity constraints), the raw parameter values are often fairly opaque. This class provides more clarity on the raw and transformed parameter values used in a particular GP.

The class is a wrapper around the numpy array holding the raw data values. When initializing a new GPParams object, the data can optionally be specified to initialize the array. Otherwise, a default value of None will be used to indicate that the GP has not been fit.

Parameters:
  • n_mean (int) – The number of parameters in the mean function. Optional, default is 0 (zero or fixed mean function). Must be a non-negative integer.
  • n_corr (int) – The number of correlation length parameters. Optional, default is 1. This must be the same as the number of inputs for a particular GP. Must be a positive integer.
  • nugget (str or float) – String or float specifying how nugget is fit. If a float, a fixed nugget is used (and will fix the value held in the GPParams object). If a string, can be 'fit', 'adaptive', or 'pivot'.

The transformations between the raw parameters \(\theta\) and the transformed ones \((\beta, l, \sigma^2, \eta^2)\) are as follows:

  1. Mean: No transformation; \({\beta = \theta}\)
  2. Correlation: The raw values are transformed via \({l = \exp(-0.5\theta)}\) such that the transformed values are the correlation length associated with the given input.
  3. Covariance: The raw value is transformed via \({\sigma^2 = \exp(\theta)}\) so that the transformed value is the covariance.
  4. Nugget: The raw value is transformed via \({\eta^2 = \exp(\theta)}\) so that the transformed value is the variance associated with the nugget noise.
corr

Transformed correlation length parameters

The corr property returns the part of the data array, with transformation, associated with the correlation lengths. Transformation is done via via \({l = \exp(-0.5\theta)}\). Returns a numpy array of length (n_corr,) or None if the data array has not been initialized.

Can be set with a new numpy array of the correct length. New parameters must satisfy the positivity constraint and all be \(> 0\). If the data array has not been initialized, then setting individual parameter values cannot be done.

Returns:Numpy array holding the transformed correlation parameters
Return type:ndarray
corr_raw

Raw Correlation Length Parameters

This is used in computing kernels as the kernels perform the parameter transformations internally.

cov

Transformed covariance parameter

The cov property returns the covariance transformed according to \(\sigma^2=\exp(\theta)\). Returns a float or None if the data array has not been initialized.

Can be set with a new float \(>0\) or numpy array of length 1 holding a positive float. If the data array has not been initialized, then setting individual parameter values cannot be done.

Returns:Transformed covariance parameter
Return type:float or None
cov_index

Determine the location in the data array of the covariance parameter

get_data()

Returns current value of raw parameters as a numpy array

Provides access to the underlying data array for the GPParams object. Returns a numpy array or None if the parameters of this object have not yet been set.

Returns:Numpy array holding the raw parameter values
Return type:ndarray or None
mean

Mean parameters

The mean property returns the part of the data array associated with the mean function. Returns a numpy array of length (n_mean,) or None if the mean data has not been initialized.

Can be set with a new numpy array of the correct length.

Returns:Numpy array holding the mean parameters
Return type:ndarray
n_params

Number of fitting parameters stored in data array

This is the number of correlation lengths plus one (for the covariance) and optionally an additional parameter if the nugget is fit.

nugget

Transformed nugget parameter

The nugget property returns the nugget transformed via \(\eta^2=\exp(\theta)\). Returns a float or None if the emulator parameters have not been initialized or if the emulator does not have a nugget.

Can be set with a new float \(>0\) or numpy array of length 1. If the data array has not been initialized or the emulator has no nugget, then the nugget setter will return an error.

Returns:Transformed nugget parameter
Return type:float or None
nugget_type

Method used to fit nugget

Returns:string indicating nugget fitting method, either "fixed", "adaptive", "pivot", or "fit"
Return type:str
same_shape(other)

Test if two GPParams objects have the same shape

Method to check if a new GPParams object or numpy array has the same length as the current object. If a numpy array, assumes that the array represents the fitting parameters and that the mean parameters will be handled separately. If a GPParams object, it will also check if the number of mean parameters match.

Returns a boolean if the number of mean (if a GPParams object only), correlation, and nugget parameters (for a numpy array or a GPParams object) are the same in both object.

Parameters:other (GPParams or ndarray) – Additional instance of GPParams or ndarray to be compared with the current one.
Returns:Boolean indicating if the underlying arrays have the same shape.
Return type:bool
set_data(new_params)

Set a new value of the raw parameters

Allows the data underlying the GPParams object to be set at once. Can also be used to reset the underlying data to None for the full array, indicating that no parameters have been set. Note that setting the data re-initializes the mean and (if necessary) covariance and nugget.

Parameters:new_params (ndarray or None) – New parameter values as a numpy array with shape (n_params,) or None.
Returns:None