py4sci

Table Of Contents

Previous topic

Callbacks

Next topic

Sensitivity Analysis

This Page

Calibration of Input Variables

Frequently computer models will have input parameters that cannot be measured and are not well known. In this case, Bayesian calibration can be used to estimate the input parameters. To do this, experimental data is required for the output and for all known input variables. The calibration process adjusts the unknown parameters to fit the observed data.

Using PUQ for Calibration

To use PUQ to do calibration, you will have to add experimental data to all the known input parameters. For the TestProgram, you will need to add experimental data and (optionally) a measurement error. The measurement error is a standard deviation.

The presence of experimental data tells PUQ to do calibration. The steps are as follows:

  1. Build a response surface over the range of the input paramaters.
  2. Do Bayesian calibration using the response surface for the likelihood function.
  3. Manually adjust calibrated input parameter PDFs, if necessary. For example, truncate PDFs that go negative.
  4. Generate output PDF.

Example

test2 in puq/examples/calibrate calibrates z. The experimental data was generated using a z with a Normal distribution of 12 and deviation of 2. Some noise was added with a sigma of 0.1. For calibration we use a uniform prior [5, 20] for z.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import puq
import numpy as np

def run():

    # experimental data for z=Normal(12,2)
    exp_x =np.array([5.04,  5.14,  4.78,  5.12,  5.11,  5.13,  4.97,  5.1 ,  5.53,  5.09])
    exp_y = np.array([3.33,  3.56,  2.94,  3.27,  3.54,  3.4 ,  3.52,  3.63,  3.45,  3.19])
    exp_data = np.array([-26.16, -18.39, -20.57, -45.24, -29.16, -22., -46.47,  -3.15, -10.48, -16.88])

    # measurement error
    sigma = 0.1

    # Create parameters. Pass experimental input data to
    # non-calibration parameters.
    x = puq.NormalParameter('x', 'x', mean=5, dev=0.2, caldata=exp_x)
    y = puq.NormalParameter('y', 'y', mean=3.4, dev=0.25, caldata=exp_y)
    z = puq.UniformParameter('z', 'z', min=5, max=20)

    # set up host, uq and prog normally
    host = puq.InteractiveHost()
    uq = puq.Smolyak([x,y,z], level=2)
    prog = puq.TestProgram('./model_1.py', desc='model_1 calibration')

    # pass experimental results to Sweep
    return puq.Sweep(uq, host, prog, caldata=exp_data, calerr=sigma)
~/puq/examples/calibrate> puq start test2.py
Saving run to sweep_85212814.hdf5

Processing <HDF5 dataset "f": shape (25,), type "<f8">
        Surface   = 1.0*x**2 + 1.0*x*y + 0.75*y**2 + 2.0*y - 7.0*z + 2.0
        RMSE      = 2.15e-11 (1.74e-11 %)

SENSITIVITY:
Var      u*            dev
-----------------------------
z    1.0500e+02    1.8394e-11
y    1.8630e+01    1.1297e+00
x    1.6505e+01    1.0054e+00
Performing Bayesian Calibration...
[****************100%******************]  12000 of 12000 complete
Calibrated z to Normal(12.0786402402, 2.2152608414).