calibration module
- class surmise.calibrator(x, y, yvar, thetaprior, args, emu, method='directbayes')[source]
A class to represent a calibrator. Fits a calibrator model provided in
calibrationmethods/[method].pywhere [method] is the user option with default listed above. Refer to the documentation (usage examples) for more details.Tip
To use a new calibrator, just drop a new file to the
calibrationmethods/directory with the required formatting.- Parameters:
x (numpy.ndarray) – An array of x values that match the definition of “emu.x”. Currently, existing methods supports only the case when x is a subset of “emu.x”.
y (numpy.ndarray) – Array of observed values at x.
yvar (numpy.ndarray) – The vector of observation variances at y.
thetaprior (class) –
class instance with two built-in functions.
Important
If a calibration method requires sampling, then the prior distribution of the parameters should be included into the calibrator. In this case, thetaprior class should include two methods:
lpdf(theta)Returns the log of the pdf of a given theta with size
(len(theta), 1)
rnd(n)Generates n draws of a random variable from the prior distribution.
- Example:
class prior_example: def lpdf(theta): return sps.uniform.logpdf( theta[:, 0], 0, 1).reshape((len(theta), 1)) def rnd(n): return np.vstack((sps.uniform.rvs(0, 1, size=n)))
args (dict) –
Dictionary containing options you would like to pass to the [method].fit() or [method].predict() calibrator functions.
For example, see
tests.shared_scenario.DEAFULT_MH_SPECS.emu (surmise.emulator) – An emulator class instance as defined in surmise.
method (str, optional) – A string that points to the file located in
calibrationmethods/you would like to use.
- class surmise.calibration.prediction(info, cal)[source]
Bases:
objectA class to represent a calibration prediction. predict.info will give the dictionary from the method.
- Example:
prediction.lpdf() prediction.mean() prediction.var() prediction.rnd()
- empirical_coverage(p=array([0.68, 0.9, 0.95, 0.99]))[source]
Computes empirical coverage given predictions using samples collected from calibration.