emulation module

class surmise.emulator(x=None, theta=None, f=None, method='PCGP', passthroughfunc=None, args={}, options={})[source]

A class used to represent an emulator or surrogate model. Fits an emulator or surrogate model provided in emulationmethods/[method].py where [method] is the user option with default listed above.

Tip

To use a new emulator, just drop a new file to the emulationmethods/ directory with the required formatting.

Example:
emulator(x=x, theta=theta, f=f, method='PCGP', args=args)
Parameters:
  • x (numpy.ndarray, optional) – An array of inputs. Each row should correspond to a row in f. The default is None. We will attempt to resolve size differences.

  • theta (numpy.ndarray, optional) – An array of parameters. Each row in theta should correspond to a column in f. The default is None. We will attempt to resolve size differences.

  • f (numpy.ndarray, optional) – An array of responses with ‘nan’ representing responses not yet available. The default is None. Each column in f should correspond to a row in x. Each row should correspond to a row in f. We will attempt to resolve if these are flipped.

  • method (str, optional) – A string that points to the file located in emulationmethods/. The default is PCGP.

  • passthroughfunc (function, optional) – DESCRIPTION. The default is None.

  • args (dict, optional) – Optional dictionary containing options you would like to pass to [method].fit(x, theta, f, args) or [method].predict(x, theta, args) The default is {}.

  • options (dict, optional) – Dictionary containing options you would like emulation to have. This does not get passed to the method. The default is {}.

class surmise.emulation.prediction(_info, emu)[source]

Bases: object

A class to represent an emulation prediction. predict._info returns the dictionary from the method.

Example:
prediction.mean()

prediction.var()

prediction.covx()

prediction.rnd()
covx(args=None)[source]

Returns the covariance matrix at theta and x when building the prediction.

covxhalf(args=None)[source]

Returns the sqrt of the covariance matrix at theta and x when building the prediction. That is, if this returns A = predict.covhalf(.)[k], then A.T @ A = predict.cov(.)[k]

covxhalf_gradtheta(args=None)[source]

Returns the gradient of the covxhalf matrix at theta and x when building the prediction.

lpdf(f=None, args=None)[source]

Returns a log pdf at theta and x

lpdf_gradtheta(f=None, args=None)[source]

Returns a log pdf at theta and x

mean(args=None)[source]

Returns the mean at theta and x in when building the prediction.

mean_gradtheta(args=None)[source]

Returns the gradient of the mean at theta and x with respect to theta when building the prediction.

save_to(filename)[source]

Simple serialization and saving function for prediction object.

Example:

emu = emulator(...)

emupred = emu.predict(...)

emupred.save_to('emupred_example.pkl')

loaded_emupred = emulator.load_prediction('emupred_example.pkl')
var(args=None)[source]

Returns the pointwise variance at theta and x when building the prediction.